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     }

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

  • 相关阅读:
    word2vec原理
    tensorboard
    更换pip源到国内镜像
    pycharm打包exe
    whl文件下载
    pycharm连git和gitee
    Django基础
    mysql相关
    安装anaconda及pytorch
    VSCode 配置python
  • 原文地址:https://www.cnblogs.com/jingyi17/p/10233613.html
Copyright © 2011-2022 走看看