zoukankan      html  css  js  c++  java
  • mybatis将传入0识别成空字符串

    mybatis将传入的Integer类型的0被识别成空字符串,网上的解决办法:

    <if test="status != null and status != '' or status == 0">
      and status = #{status, jdbcType = INTEGER}
    </if>

    然而还是有无效的时候。既然status==''时无效,就将其置为null。此时就在Java中对该参数进行处理,当 status == '' 时将其赋值为 null。

     1    @PostMapping(value = "/listUser")
     2     public Object listUser(@RequestBody Map<String, Object> params) {
     3         try { 8             if(("").equals(params.get("status"))) {
     9                 params.put("status", null);
    10             }
    11             List<SysUser> listUser = userService.listUser(params);
    12             return listUser;
    13         } catch (Exception e) {
    14             logger.error("获取用户信息异常=====>" + e.getMessage());16         }
    17     }

    或许还有其它的办法,多多尝试。

  • 相关阅读:
    前端知识之JavaScript内容(一)
    前端2css层叠样式表
    前端:html初识以及标签
    css
    python--re模块(正则表达式)
    python--xml模块
    关于导包问题
    前端浅了解
    试写仿优酷系统坑点
    sqlalchemy
  • 原文地址:https://www.cnblogs.com/jingyi17/p/10233613.html
Copyright © 2011-2022 走看看