mybatis 部分符号需转译 及 IF如何正确判断单个数字字符
mybatis 部分符号需转译 及 IF如何正确判断单个数字字符
1、Mybatis 转译字符如下下法即可:
<号是用特殊字符代替的哦,直接写<号程序会报错的
| Mybatis转义字符表(记得这列在使用时候加; ) | ||
|---|---|---|
| < | < | 小于 |
| > | > | 大于 |
| & | & | 与 |
| &apos | ' | 单引号 |
| " | " | 双引号 |
如下示例:
<!-- 通用查询条件 -->
<sql id="Base_Search">
<if test="content != null">
AND CONTENT like '%'||#{content,jdbcType=VARCHAR}||'%'
</if>
<if test="createdBy != null">
AND CREATED_BY = #{createdBy,jdbcType=VARCHAR}
</if>
<!-- 提交时间start -->
<if test="startTime !=null">
AND CREATION_TIME >= to_date(#{startTime},'yyyy-MM-dd hh24:mi:ss')
</if>
<!-- 提交时间end -->
<if test="endTime !=null">
AND CREATION_TIME <= to_date(#{endTime},'yyyy-MM-dd hh24:mi:ss')
</if>
</sql>
第二种方案
<![CDATA[ when min(starttime)<='12:00' and max(endtime)<='12:00' ]]>
2、mybatis的IF如何正确判断单个数字字符
传入参数 itemCode=“1”
以下写法不符合判断
<if test='itemCode != null and itemCode !="" and itemCode =="1" '>
如果想让判断符合条件,可以使用一下两种写法
<if test="itemCode != null and itemCode !='' and itemCode =='1'.toString()">
或
<if test='itemCode != null and itemCode !="" and itemCode =="1" '>
白茶清欢无别事,我在等风也等你,苦酒折柳今相离,无风无月也无你。

浙公网安备 33010602011771号