mybatis中使用小于号
mybatis中小于号没有办法直接写。
·
mybatis中小于号没有办法直接写
- 方式一需要使用特殊转义字符:
<
例子
<select id="selectRolesPage" parameterType="java.util.Map" resultType="com.leilankeji.cn.dao.SysRole" >
select
*
from t_sys_role
<where>
<if test="roleName != null and roleName != ''">
and role_name like concat('%',#{roleName},'%')
</if>
<if test="beginTime">
and create_time >= #{beginTime}
</if>
<if test="endTime">
and create_time <= #{endTime}
</if>
<if test="status!= null">
and status = #{status}
</if>
</where>
</select>
- 方式二 使用 <![CDATA[ ?]]> 符号
?代表的是需要不想被解析的文本
<select id="selectRolesPage" parameterType="java.util.Map" resultType="com.leilankeji.cn.dao.SysRole" >
select
*
from t_sys_role
<where>
<if test="roleName != null and roleName != ''">
and role_name like concat('%',#{roleName},'%')
</if>
<if test="beginTime">
and create_time >= #{beginTime}
</if>
<!-- <if test="endTime">-->
<!-- and create_time <= #{endTime}-->
<!-- </if>-->
<if test="endTime">
and create_time <![CDATA[<=]]> #{endTime}
</if>
<if test="status!= null">
and status = #{status}
</if>
</where>
</select>
更多推荐
所有评论(0)