1.对于 byte int等pojo中属性判断的时候
注意不可以是这种情况
<if test="newsType != null"> and news_type = #{newsType} </if> <if test="newsNature != null and newsNature != ''"> and news_nature = #{newsNature} </if>
其中newType 和 newsNature在pojo中是Byte类型, 当newsType和newsNature 都不为空的时候,第一次请求的时候 and news_type = #{newsType}会拼接到sql中而 and news_nature = #{newsNature}不会拼接到sql中;当第二次请求这个sql的时候都会拼接到sql ,也就是说对于 newsNature的判断,当多了不为“”条件限制的时候会出错!具体原因不清楚 。去掉上面
and newsNature != ''
就正常了。