mybatis代码一样却报错

正确的
test="volume!=null and vloume!=' '"

错误的
test="volume!=null and volume!=' '"

第一段代码没有问题 然后带二段代码写上去就报错

    <select id="alist" parameterType="hashmap" resultType="android">
        select * from Android
        where 1=1
        <if test="version!=null and version!=' '">
            and version>#{version}
    </if>
        <if test="volume!=null and vloume!=' '">
            and volume like "${volume}%";
    </if>
    </select>
    <select id="ddlist" parameterType="hashmap" resultType="Android">
        select * from Android
        <where>
            <if test="version!=null and version!=' '">
                and version>#{version}
</if>
            <if test="volume!=null and volume!=' '">
                and volume like "${volume}%";
</if>
        </where>

    </select>

控制台报错代码

log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NumberFormatException: For input string: "十"
### Cause: java.lang.NumberFormatException: For input string: "十"
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
    at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
    at $Proxy0.alist(Unknown Source)
    at com.hy.am.test.Select1.main(Select1.java:28)
Caused by: java.lang.NumberFormatException: For input string: "十"
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
    at java.lang.Double.parseDouble(Double.java:510)
    at org.apache.ibatis.ognl.OgnlOps.doubleValue(OgnlOps.java:259)
    at org.apache.ibatis.ognl.OgnlOps.compareWithConversion(OgnlOps.java:143)
    at org.apache.ibatis.ognl.OgnlOps.isEqual(OgnlOps.java:186)
    at org.apache.ibatis.ognl.OgnlOps.equal(OgnlOps.java:578)
    at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:51)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.ASTAnd.getValueBody(ASTAnd.java:56)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:395)
    at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:48)
    at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
    at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:33)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
    at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:40)
    at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:278)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:75)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
    ... 6 more

有没有大佬清楚这个是什么原因啊

3个回答

你仔细看下你的代码volumn写的一不一样,看到就发现了

![图片说明](https://img-ask.csdn.net/upload/201909/22/1569138286_98159.png)

Cause: java.lang.NumberFormatException: For input string: "十" 你的数据转化 string类型错了 你看看map传参对不

qq_43739616
净眼浊目皆虚渺 map没得问题 只是那个volume!=‘’中间不能加空格
3 个月之前 回复

两个参数不一致,完了返回参数的大小写也不一致

qq_43739616
净眼浊目皆虚渺 多谢
3 个月之前 回复
qq_43739616
净眼浊目皆虚渺 晓得了
3 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问