MyBatis学习之mapper.xml中SQL处理小于号与大于号等比较符号

MyBatis mapper.xml中SQL处理小于号与大于号等比较符号

前端时间学习mybatis,在IDE中编写sql语句时,<=号报错,于是看了mybatis的文档,原来是有相关的符号代替了。这里记录一下。

1、常用转义符号

< <= > >= & ' "
&lt; &lt;= &gt; &gt;= &amp; &apos; &quot;

2、详情解释

这些字符其实是转义字符,和HTML,xml等其它语言的的转义字符一样。如果有熟悉的兄弟就知道了。
例如:>=,其实只需要转义>号即可。转义为&gt;=号不需要转义

3、代码中使用

<select id="select" parameterType="xxx" resultMap="xxx">  
    select * from user
    <where>  
        <if test="age!= null">  
            age &gt;= #{age}  
        </if>  
    </where>  
</select> 

猜你喜欢

转载自blog.csdn.net/u012489412/article/details/80783050