使用mybatis的时候,特殊字符,例如<,>,<>,.....

需使用以下进行转义

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
&lt; < 小于号  
&gt; > 大于号
&amp; &  
&apos; ' 单引号
&quot; " 双引号

 

    <select id="selectByExampleExt" parameterType="com.cn21.redisCluster.model.AppInfoExampleExt" resultMap="BaseResultMapExt"> SELECT temp.*,r.* from ( SELECT a.* from appinfo as a where 1=1 <if test="appid != null and appid != '' "> and a.appid=#{appid,jdbcType=VARCHAR} </if> <if test="productid != null"> and a.productid=#{productid,jdbcType=INTEGER} </if> ORDER BY a.lastupdatetime DESC <if test="limitStart&gt;=0 and limit&gt;0"> (这里就是类似的 <if test="limitStart>=0 and limit>0"> LIMIT ${limitStart} , ${limit} </if> <if test="limitStart==-1 and limit&gt;0"> LIMIT ${limit} </if> ) temp,redisdb r where temp.appid = r.appid </select>

 

,

使用mybatis的时候,特殊字符,例如<,>,<>,.....

需使用以下进行转义

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

 

    <select id="selectByExampleExt" parameterType="com.cn21.redisCluster.model.AppInfoExampleExt" resultMap="BaseResultMapExt"> SELECT temp.*,r.* from ( SELECT a.* from appinfo as a where 1=1 <if test="appid != null and appid != '' "> and a.appid=#{appid,jdbcType=VARCHAR} </if> <if test="productid != null"> and a.productid=#{productid,jdbcType=INTEGER} </if> ORDER BY a.lastupdatetime DESC <if test="limitStart&gt;=0 and limit&gt;0"> (这里就是类似的 <if test="limitStart>=0 and limit>0"> LIMIT ${limitStart} , ${limit} </if> <if test="limitStart==-1 and limit&gt;0"> LIMIT ${limit} </if> ) temp,redisdb r where temp.appid = r.appid </select>

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄