zoukankan      html  css  js  c++  java
  • 通过xml处理sql语句时对小于号与大于号的处理转换

      当我们需要通过xml格式处理sql语句时,经常会用到< ,<=,>,>=等符号,但是很容易引起xml格式的错误,这样会导致后台将xml字符串转换为xml文档时报错,从而导致程序错误。

      这样的问题在iBatiS中或者自定义的xml处理sql的程序中经常需要我们来处理。其实很简单,我们只需作如下替换即可避免上述的错误:

    原符号  <  <=   > >=   &   '   "
    替换符号 &lt; &lt;= &gt; &gt;= &amp; &apos; &quot;

    错误格式如下:

        <select id="fenye" parameterType="Map" resultMap="users">
      		select * from 
      		<trim prefix="(" suffix=") b">
      			select a.*,rownum rn from
      			<trim prefix="(" suffix=") a">
      				select * from test t order by t.id desc 
      			</trim>
      			<!-- <if test="size!=null">
      				rownum<=#{size}
      			</if> -->
      		</trim>
      		<where>
      			b.rn < #{size}
      		</where>
      	</select>
    

    正确格式如下:

    <select id="fenye" parameterType="Map" resultMap="users">
      		select * from 
      		<trim prefix="(" suffix=") b">
      			select a.*,rownum rn from
      			<trim prefix="(" suffix=") a">
      				select * from test t order by t.id desc 
      			</trim>
      			<!-- <if test="size!=null">
      				rownum<=#{size}
      			</if> -->
      		</trim>
      		<where>
      			b.rn < #{size}
      		</where>
      	</select>
    

      

  • 相关阅读:
    iOS Provision 要点记录
    (FIFO)有名管道在无亲缘进程间的通信
    uuid Makefile share
    浅谈C语言中的联合体
    消息队列 进程通信
    onvif makefile without share
    共享内存 进程通信
    共享内存(非map) 进程通信
    消息队列 两个进程
    linux 进程通信
  • 原文地址:https://www.cnblogs.com/claricre/p/6744271.html
Copyright © 2011-2022 走看看