java xml中sql處理大於號與小於號


這種問題在xml處理sql的程序中經常需要我們來進行特殊處理。

其實很簡單,我們只需作如下替換即可避免上述的錯誤:

< <= > >= & ' "

&lt;

&lt;=

&gt;

&gt;=

&amp;

&apos;

&quot;

 

例如常見的時間比較:

<select id="select" parameterType="xxx" resultMap="xxx">
    select
        distinct
        <include refid="Base_Column_List" />
    from xxx
    <where>
        <if test="createDate != null">
            create_date <= #{createDate}
        </if>
    </where>
</select>

正確寫法:

<select id="select" parameterType="xxx" resultMap="xxx">
    select
        distinct
        <include refid="Base_Column_List" />
    from xxx
    <where>
        <if test="createDate != null">
            create_date &lt;= #{createDate}
        </if>
    </where>
</select>

 

 

 

轉自:https://www.cnblogs.com/qingmuchuanqi48/p/11839253.html


免責聲明!

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



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