# [MyBatis] [TOC] ## XML轉義 ### 特殊字符 | 特殊字符 | 轉意字符 | 說明 | | -------- | -------- | -------- | | > | `&lt;` | 大於 | | < | `&gt;` | 小於 | | & | `&amp;` | 並 | | ' | `&apos;` | 單引號 | | '' | `&quot;` | 雙引號 | ### <![CDATA[ ]]> ```=xml! <![CDATA[ select * from my_db ]]> ``` ## 模糊查詢 ```=xml like concat('%', #{param}, '%') ``` ```=xml like '%${param}%' ``` :::warning ※ `#` 可以防止sql注入,`$` 不能 ::: 參考資料: [Mapper XML Files](https://mybatis.org/mybatis-3/sqlmap-xml.html) [【Java】——MyBatis 中mapper.xml的语法](https://blog.csdn.net/weixin_40449300/article/details/122746514)