记一次数据查询不到问题

后端开发人员在查询数据时把参数


手动写了 2,4,5
mapper层是用的string接收

但是xml中也是直接 in()拼接
导致数据库以为2,4,5是一个字符串,所以查询不到数据
修正前:

<if test="auditStatus !=null and auditStatus!=''">
            and car.AUDIT_STATUS in
                #{auditStatus}
</if>

修正后:

记一次接口调优方案

以前的项目,今天让我数据优化,花了一天多时间把业务重写下

不要再循环中进行数据库查询语句
可以选用直接在外面把全部数据查询出来
然后用代码去遍历查询数据

用内存换时间
目前我优化后效率从7s到2s左右

再做接口开发时,遇到一个问题 Could not resolve view with name 'xxx' in servlet with name 'dispatcherServlet'

用的springboot框架

在控制器上加了 两个注解

@Controller
@RequestMapping("/kingowSSO")

我写了一个方法,
刚开始我的方法没有这个注解,当请求过来时方法可以正常执行,但是方法执行完毕后,程序会报错,挺奇怪的,我的方法没有返回值用的 void ,理论上是不需要加 @ResponseBody 注解的才对啊

@ResponseBody

但是不加 @ResponseBody 注解 程序会报错

Could not resolve view with name 'xxx' in servlet with name 'dispatcherServlet'

java计算百分比

/**
     * 使用java.text.DecimalFormat实现
     *
     * @param x
     * @param y
     * @return
     */
    public static String getPercent(int x, int y) {
        if (x == 0) return "0.00%";
        double d1 = x * 1.0;
        double d2 = y * 1.0;
        // 设置保留几位小数, “.”后面几个零就保留几位小数,这里设置保留两位小数
        DecimalFormat decimalFormat = new DecimalFormat("##.00%");
        return decimalFormat.format(d1 / d2);
    }
 /**
     * 方式一:使用java.text.NumberFormat实现
     * @param x
     * @param y
     * @return
     */
    public static String getPercent(int x, int y) {
        double d1 = x * 1.0;
        double d2 = y * 1.0;
        NumberFormat percentInstance = NumberFormat.getPercentInstance();
        // 设置保留几位小数,这里设置的是保留两位小数
        percentInstance.setMinimumFractionDigits(2);
        return percentInstance.format(d1 / d2);
    }