在mapper的xml配置中,如下:
<select id="ListUserLog" resultMap="BaseResultMap">
select * from cms_sys_managerLog
<where>
1 = 1
<if test="type > 0">
and type = #{type}
</if>
<if test="userName !=null and userName !=''">
and create_user like "%"#{userName}"%"
</if>
<if test="modelName !=null and modelName !=''">
and model_name like "%"#{modelName}"%"
</if>
<if test="from != null">
and create_date >= #{from}
</if>
<if test="to != null">
and create_date <![CDATA[ < ]]> #{to}
</if>
</where>
ORDER BY id DESC
<if test="curPage > 0 and pageSize > 0">
LIMIT (#{curPage}-1)*#{pageSize},#{pageSize}
</if>
</select>
但是执行的时候报错:
## Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(1-1)*10,10' at line 13
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(1-1)*10,10' at line 13 at
我就想要这么实现,要怎么才能好使呢,求大神赐教。。。。。。。
mybatis sql select mysql xml
------解决方案--------------------
queryForList("xxx", map,(pageNum - 1) * pageSize, pageSize)
------解决方案--------------------
值是传进来的,在外面也可以先 处理
------解决方案--------------------
你这个事webservice传过来的嘛,你计算后put到map中,吧map传进去就是了撒...
------解决方案--------------------
CDATA好使吗,或者转义下
------解决方案--------------------
LIMIT (#{curPage}-1)*#{pageSize},#{pageSize}换成LIMIT (${curPage}-1)*#{pageSize},#{pageSize}试试吧,不过$不会预编译,可能有漏洞