Home > Database > Mysql Tutorial > mybaits的xxMapper.xml文件中大于号和小于号处理

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

WBOY
Release: 2016-06-07 16:01:42
Original
1604 people have browsed it

第一种方法: 因为这个是xml格式的,所以不允许出现类似这样的字符,但是都可以使用![CDATA[ ]]符号进行说明,将此类符号不进行解析 。 mapper文件示例代码: select id=selectMonthAdvertise resultMap=ResultMap select * from ad_n_advertise_t where use

第一种方法:

因为这个是xml格式的,所以不允许出现类似“>”这样的字符,但是都可以使用符号进行说明,将此类符号不进行解析 。 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>
Copy after login
第二种方法: 用了转义字符把>和<替换掉。 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>
Copy after login
附:转义字符表。
< < 小于号
> > 大于号
& &
' ' 单引号
" " 双引号
mapper文件示例代码:
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template