1. 程式人生 > >Mybatis特殊字符處理

Mybatis特殊字符處理

asi off phone XML .sh 解析 com ron reat

XML文檔中包含類似"Elements look like <this>"的文本,其中的"<this>"將被解析程序解釋成一個元素,而人們實際想要的是"<this>"所表示的原義文本。

1.CDATA區:它的全稱為character data,以"<![CDATA[ "開始,以" ]]>" 結束,在兩者之間嵌入不想被解析程序解析的原始數據,解析器不對CDATA區中的內容進行解析,而是

將這些數據原封不動地交給下遊程序處理。

2.特殊字符 :

xml 中表示: <= 小於等於、 >= 大於等於 需加 這樣的標記: <![CDATA[ ]]>

xml中有&的符號,需要<![CDATA[&]]>這樣表示&

<= 小於等於 :<![CDATA[ <= ]]>

>= 大於等於:<![CDATA[ >= ]]>

一些特殊字符也可用下面的替代符號所代替。

特殊字符 替代符號

& &amp;

< &lt;

> &gt;

" &quot;

‘ &apos;

例:

<select id="selectPaymentOrder" parameterType="com.shenxin.basis.basismag.entity.PaymentOrderInfoDO"
resultType="com.shenxin.basis.basismag.entity.PaymentOrderInfoDO">
select t0.payment_order_code paymentOrderCode,
t0.BUSINESS_CODE userName,
‘‘ userPhone,
t0.payment_channel paymentChannel,
t4.type_code typeCode,
t4.type_name typeName,
t0.item_code itemCode,
‘光大‘ proOrg,
t1.item_name itemName,
t0.order_amount orderAmount,
t0.order_status orderStatus,
t2.order_status sendOrderStatus,
t0.create_date createDate,
t0.update_date updateDate,
t0.payment_Channel_Code transId,
‘1‘ channelId
from pfb_payment_order_info t0
left join pfb_item_info t1 on t0.item_code=t1.item_code
left join PFB_CHARGEOFF_ORDER_INFO t2 on t0.payment_order_code=t2.payment_order_code
left join pfb_item_info t3
left join pfb_item_type t4 on t3.trade_type=t4.type_code
on t3.item_code=t0.item_code
where 1=1
<if test="userName != null and userName != ‘‘"> AND t0.BUSINESS_CODE like ‘%‘||#{userName}||‘%‘ </if>
<if test="paymentOrderCode != null and paymentOrderCode != ‘‘"> AND t0.payment_order_code like ‘%‘||#{paymentOrderCode}||‘%‘ </if>
<if test="orderStatus != null and orderStatus != ‘‘"> AND t0.order_status=#{orderStatus} </if>
<if test="typeCode != null and typeCode != ‘‘"> AND t4.type_code=#{typeCode} </if>
<if test="startTime != null and startTime != ‘‘"> AND to_char(to_date(t0.create_date,‘yyyy-mm-dd,hh24:mi:ss‘),‘yyyymmdd‘)>#{startTime} </if>
<if test="endTime != null and endTime != ‘‘"> AND to_char(to_date(t0.create_date,‘yyyy-mm-dd,hh24:mi:ss‘),‘yyyymmdd‘)<![CDATA[<]]>#{endTime} </if>
</select>

Mybatis特殊字符處理