mybatis异常:The content of elements must consist of well-formed character data or markup
使用查詢如下:
select MERCHANT_NO from MI_MIDATRD where MERCHANT_NO = #{merchno} and ( (status = 'Y' or status = 'B') and CREATE_DATE <= TO_DATE(#{billdate},'YYYYMMDD')
執行時出現exception: ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 24; The content of elements must consist of well-formed character data or markup. at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:79) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:71) at com.ctbc.util.sql.MyBatisUtil.getsqlSessionFactory(MyBatisUtil.java:51) .... 後來發現原來是“<"這個符號導致的問題,依照參考網頁改成如下:
select MERCHANT_NO from MI_MIDATRD where MERCHANT_NO = #{merchno}
and ( (status = 'Y' or status = 'B')
<![CDATA[
and CREATE_DATE <= TO_DATE(#{billdate},'YYYYMMDD')
]]>
and DELETE_DATE is null)
就解決囉~~
沒有留言:
張貼留言