Mybatis特殊字符处理[L]

xiaoxiao2021-02-28  92

XML文档中包含类似"Elements look like <this>"的文本,其中的"<this>"将被解析程序解释成一个元素,而人们实际想要的是"<this>"所表示的原义文本。

1.CDATA区:它的全称为character data,以"<![CDATA[ "开始,以" ]]>" 结束,在两者之间嵌入不想被解析程序解析的原始数据,解析器不对CDATA区中的内容进行解析,而是

将这些数据原封不动地交给下游程序处理。

2.特殊字符 :

xml 中表示:   <= 小于等于、    >= 大于等于 需加  这样的标记:     <![CDATA[   ]]>      xml中有&的符号,需要<![CDATA[&]]>这样表示&

 

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

 

 

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

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

 特殊字符   替代符号

     &            &

     <            <

     >            >

     "             "

     '              '

 

例:

<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>

转载请注明原文地址: https://www.6miu.com/read-96916.html

最新回复(0)