mybatis mapper 添加自定義標簽


1 <select>
2 select * from t where xx=xx and 
3 <myTag xx="xx">
4 xxx
5 </myTag>
6 </select>

1、使用CDATA

1 <select>
2  select * from t where xx=xx and 
3  <![CDATA[[
4 <myTag xx="xx">
5  xxx
6  </myTag>
7 ]]>
8 </select>

2、不用CDATA,修改dtd,擴展解析mapper的相關類

2.1 修改dtd,放到mybatis指定的路徑,覆蓋mybatis自帶的dtd

2.2

1)自定義XMLScriptBuilder(customXMLScripteBuilder),往map中put mytag標簽及其處理器

2)繼承XMLLanguageDriver(extendXMLLanguageDriver),重寫createSqlSource的方法,使用customXMLScriptBuilder

3)繼承TypeAliasRegistry(ExtendTypeAliasRegistry),提供一個方法往mapper中重新添加xml處理類extendXMLLanguageDriver,覆蓋的XMLLanguageDriver

4)繼承Configuration(ExtendConfiguration),提供一個方法setTypeAliasRegistry,把ExtendTypeAliasRegistry的對象set進去


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM