在mybatis中對sql語句中涉及到大於號,小於號,如何操作:
方法一、
將其放入到<![CDATA[ ]]>標簽中
如:
- <![CDATA[
- and mm.ttime > to_date(#{startDateTime},'yyyy-mm-dd hh24:mi:ss')
- and mm.ttime <= to_date(#{endDateTime},'yyyy-mm-dd hh24:mi:ss')
- ]]>
方法二、
如果是在動態語句中,則需要轉換
如:
- <if test="startDateTime!=null"> and mm.ttime > to_date(#{startDateTime},'yyyy-mm-dd hh24:mi:ss')</if>
- <if test="endDateTime!=null"> and mm.ttime <= to_date(#{endDateTime},'yyyy-mm-dd hh24:mi:ss')</if>
符號:
< <
> >
<> <>
& &
' '
" "