码迷,mamicode.com
首页 > 移动开发 > 详细

mybaits的xxMapper.xml文件中大于号和小于号处理

时间:2014-09-01 22:47:14      阅读:1538      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   os   io   使用   strong   ar   

第一种方法:

因为这个是xml格式的,所以不允许出现类似“>”这样的字符,但是都可以使用<![CDATA[ ]]>符号进行说明,将此类符号不进行解析 。 mapper文件示例代码:

<select id="selectMonthAdvertise" resultMap="ResultMap">
   select * from ad_n_advertise_t where user_id in
  <foreach item="item" index="index" collection="userIdList" open="(" separator="," close=")">
  #{item}
  </foreach> 
  and isdelete=#{isdelete,jdbcType=TINYINT}  
  and <![CDATA[</span>date_sub(curdate(), INTERVAL 30 DAY) <= date(crt_time)]]> 
  order by crt_time desc
</select>





第二种方法:
用了转义字符把>和<替换掉。 mapper文件示例代码:
<select id="selectMonthAdvertise" resultMap="ResultMap">
   select * from ad_n_advertise_t where user_id in
  <foreach item="item" index="index" collection="userIdList" open="(" separator="," close=")">
  #{item}
  </foreach> 
  and isdelete=#{isdelete,jdbcType=TINYINT}  
  and date_sub(curdate(), INTERVAL 30 DAY) &lt= date(crt_time) 
  order by crt_time desc
</select>

附:转义字符表。

&lt; < 小于号
&gt; > 大于号
&amp; &
&apos; 单引号
  &quot;
" 双引号






 mapper文件示例代码:

mybaits的xxMapper.xml文件中大于号和小于号处理

标签:des   style   blog   color   os   io   使用   strong   ar   

原文地址:http://blog.csdn.net/wj512416359/article/details/38986423

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!