Mybatis if/when中判断字符串
无论在xml或者在@Select等注解中写的if判断的做法,经常只判断空或者''。其实还有一种可以判断字符串或者数值,代码如下:
@Select({"<script>",
"select aab001,aac001 from ab01 where aac001 is not null ",
"<if test='aab001 != null and aab001 = \"1209933\"'>",
" and aab001 = #{aab001} ",
"</if>",
"</script>"})
List<Map<String,Object>> selectPage(Page<Map<String,Object>> page, Map<String,Object> map);
其中需要注意:test需要使用单引号'。