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()-->
- NumberFormatException java quot mybatis stringnumberformatexception java quot mybatis numberformatexception cannot string问题 numberformatexception错误string flink java lang numberformatexception getsystenantnames numberformatexception常见 原因java singlequote strings quotes must string str quot字符串 tokenizetostringarray quot stringutils string quot mybatis include标签 类型string byte quot