mybatis 转义对照表
这种问题在xml处理sql的程序中经常需要我们来进行特殊处理。
其实很简单,我们只需作如下替换即可避免上述的错误:
< | <= | > | >= | & | ' | " |
< | <= | > | >= | & | ' | " |
不多说话,代码表示。
<!-- 分页查询--> <select id="getKaoShiPageList" resultMap="kaoShiBean" parameterType="com.example.demo.kaoshi.beans.kaoShiBean"> select * from tb_pxks_kaoshi <where> <if test="zy !=null and zy!= ''"> and zy='${zy}' </if> <if test="ksrqFrom !=null and ksrqFrom!= ''"> and ksrq >='${ksrqFrom}' </if> <if test="ksrqTo !=null and ksrqTo!= ''"> and ksrq <='${ksrqTo}' </if> </where> order by ksrq desc