在用于SQL select语句的mybatis映射器文件中,我无法在where表达式中使用特殊字符(<=)。例如(简化选择):
<select id="selectMonday" resultType="SheetGameRec">
select ColumnName
from Table
where ColumnName <= 2
order by ColumnName;
</select>
产生以下错误
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in Mapper.xml
### 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: xx; columnNumber: xx; The content of elements must consist of well-formed character data or markup.
如果将<=替换为> =或=,则映射器文件将起作用,尽管这不是我想要的选择。
我如何摆脱这些特殊字符。我也遇到了&等其他表达式的问题。我正在使用mybatis 3.0.2。
谢谢。
您可以CDATA
用来转义特殊字符。
<select id="selectMonday" resultType="SheetGameRec">
select ColumnName
from Table
where ColumnName <![CDATA[ <= 2 ]]>
order by ColumnName;
</select>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句