mybatis 报错:Cause: java.lang.NumberFormatException: For input string: "java"

1、所错图示:

2、为什么包这样的错误?

在if查询条件的逻辑没有错,其实在代码转换解析时,自动转换类型了,是代码在转换解析时异常。

<!--where 与if配合使用-->
<select id="selectBlogIfWhere" resultType="blog" parameterType="blog">
    <include refid="commBlog"></include>
    <where>
        <if test="title !=null and title!=' '"><!--这里报的错:java.lang.NumberFormatException-->
            and title=#{title}
        </if>
        <if test="author !=null and author!=' '">
            and author like concat('%',#{author},'%')
        </if>
        <if test="views !=null">
            and views=#{views}
        </if>
    </where>
</select>

3.解决办法:不让mybatis自动解析转换

<if test='title !=null and title!=" "'><!--单双引号互换位置-->
<if test="title !=null and title!=' '.toString()"><!--添加toString()-->    
posted @   三刀流呀  阅读(483)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示