在ibatis中的 大于等于>=及小于等于<=处理及转义字符
本文博客地址:http://blog.csdn.net/soonfly/article/details/63369700 (转载请注明出处)
使用mybatis 时sql语句是写在xml文件中,如果sql中有一些特殊的字符的话,比如< ,<=,>,>=等符号,会引起xml格式的错误,需要替换掉,或者不被转义。
有两种方法可以解决:转义字符和标记CDATA块
方式1、转义字符
<select id="searchByPrice" parameterType="Map" resultType="Product">
select * from Product where price >= #{minPrice} and price <= #{maxPrice}
select>
方式2、标记CDATA
<select id="searchByPrice" parameterType="Map" resultType="Product">
= #{minPrice} and price <= #{maxPrice} ]]>
select>
转义字符表
转义 | 符号 |
---|---|
< |
< |
> |
> |
& |
& |
' |
’ |
" |
“ |
本文博客地址:http://blog.csdn.net/soonfly/article/details/63369700 (转载请注明出处)