mybatis中date和time为stamp类型时空字符串报错

mybatis中Date或者Time是stamp不能与空字符串""比较,会抛异常

<!-- Date或者Time是stamp不能与空''字符串比较,会抛异常 -->
<if test="startDate != null and endDate != null"  >
  and MARKETDATE between #{startDate} and #{endDate}
</if>

解决方案:
入参做校验,如果date或time是空字符串,设置为null即可。代码如下:

String date="";
if(StringUtils.isBlank(date)){
    date=null;
}

``

发布了449 篇原创文章 · 获赞 17 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/enthan809882/article/details/104329267