Mybatis error: The content of the element must be composed of character data or tags in the correct format. Reasons and solutions

created at 12-14-2021 views: 10

reason

When querying mybatis, you need to use operators less than < and greater than >. In the mybatis configuration file, this is considered as a label, so the parsing error

Error example

<if test="params.perCapita != null and params.perCapita !=''">
                 and perCapita <= #{params.perCapita}
            </if>

Should be changed to:

<if test="params.perCapita != null and params.perCapita !=''">
                <![CDATA[ and perCapita <= #{params.perCapita} ]]>
            </if>
created at:12-14-2021
edited at: 12-14-2021: