欢迎关注我的公众号:零零糖,让一个贫穷的程序员不靠打代码也能吃饭~
xxx.Mapper.xml的sql中直接写">"、"<"是会报错的,需要这样写"<![CDATA[>=]]>",如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.myobject.dao.db.auto.UserMapper">
<select id="userList" parameterType="map" resultType="com.myobject.model.db.auto.User">
select
*
from user
where
is_deleted=0
<if test="user.userId!= null">
and user_id=#{user.userId}
</if>
<if test="null != user.createTimeBegin and null != user.createTimeEnd" >
and create_time <![CDATA[>=]]> #{user.createTimeBegin} and create_time <![CDATA[<=]]> #{user.createTimeEnd}
</if>
</select>
</mapper>
完。
欢迎关注我的公众号:零零糖,让一个贫穷的程序员不靠打代码也能吃饭~