mybatis中特殊符号(大于号、小于号)的处理

1、预定义字符

&lt;    <=相当于=>     < 小于号
&gt;    <=相当于=>     > 大于号

案例:

<select id="a" parameterType="java.lang.String" resultType="com.gao.entity.MyDemo">
select *
from 数据库表2
(
   select *
from 数据库表1
where id = #{id}
)
where rownum &lt;= 10
</select>

 

2、使用 CDdata

<![CDATA[sql语句]]>

案例:

    <select id="a" parameterType="java.lang.String" resultType="com.gao.entity.MyDemo">
        <![CDATA[
          select *
          from 数据库表2
              (
                   select *
                      from 数据库表1
                      where id = #{id}
              )
          where 
        rownum &lt;= 10
]]> </select>

 

 
posted @ 2022-11-13 23:38  向大海  阅读(517)  评论(0编辑  收藏  举报