1、错误日志
Caused by: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String
at org.apache.ibatis.ognl.OgnlOps.compareWithConversion(OgnlOps.java:93)
at org.apache.ibatis.ognl.OgnlOps.isEqual(OgnlOps.java:143)
at org.apache.ibatis.ognl.OgnlOps.equal(OgnlOps.java:802)
at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:53)
at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258)
at org.apache.ibatis.ognl.ASTAnd.getValueBody(ASTAnd.java:61)
2、分析原因解决
找到mybatis的xml文件,发现只有这两个字段是日期类型,仔细想了一下,那八成就是日期类型Date不能进行字符串Date != ""
判断,只进行Date != null
判断即可!
<if test='startDate != null and startDate != ""'>
start_date = #{startDate,jdbcType=TIMESTAMP},
</if>
<if test='endDate != null and endDate != ""'>
end_date = #{endDate,jdbcType=TIMESTAMP}
</if>
只需改成如下:
<if test='startDate != null'>
start_date = #{startDate,jdbcType=TIMESTAMP},
</if>
<if test='endDate != null'>
end_date = #{endDate,jdbcType=TIMESTAMP}
</if>
再次运行就妥了!!!