zoukankan      html  css  js  c++  java
  • 当我遇到了字符串等值判断的时候,坑来了

    问题描述:

    错误代码镇楼:

    <choose>
    <when test="pictureDTO.isFree = '是' ">
    1,
    </when>
    <otherwise>
    0,
    </otherwise>
    </choose>
    首先,test表达式的等值判断使用"==",弱智的我原以为会和Mysql一样用"=",然后insert的时候,字段赋值出现问题。

    改正代码一:

    <choose>
    <when test="pictureDTO.isFree == '是' ">
    1,
    </when>
    <otherwise>
    0,
    </otherwise>
    </choose>
    其次,字符串的判断,要用''里面套"",的方式,因为Mybatis是使用OGNL表达式来进行解析的。

    改正代码二:【正确代码】

    <choose>
    <when test='pictureDTO.isFree == "是" '>
    1,
    </when>
    <otherwise>
    0,
    </otherwise>
    </choose>

    错误 <if test="status == '1'">

    正确 <if test="status == '1'.toString()">

    转载于:https://www.cnblogs.com/wdw31210/p/9395898.html

  • 相关阅读:
    蓝桥杯 算法训练 ALGO-118 连续正整数的和
    迭代器和生成器
    字符串格式化
    python 赋值 深浅拷贝
    web.py
    urlib2 标准代码
    left menu
    tab menu
    modal html
    emmet使用
  • 原文地址:https://www.cnblogs.com/maohuidong/p/12143324.html
Copyright © 2011-2022 走看看