MyBatis当中模糊查询的一条示例

"<script>
select from car where 1=1
<if test=\"key!=null and key!=''\"> and car.name like CONCAT('%',#{key},'%')</if>
</script>"

这里注意判断为空和concat的使用,这样可以显著减少代码当中的if判断语句

猜你喜欢

转载自blog.csdn.net/qq_29960043/article/details/82147853