Caused by: freemarker.core.NonNumericalException: Can't convert this string to number:

一.错误显示

Caused by: 
freemarker.core.NonNumericalException: Can't convert this string to number: ""|The blamed expression:|==> (warehouseClassId)?number  [in template "/warehouse/info/list.ftl" at line 44, column 148]||The failing instruction:|==> #if warehouseClassId?? && r.id == (wa...  [in template "/warehouse/info/list.ftl" at line 44, column 114]
    at freemarker.core.NonNumericalException.newMalformedNumberException(NonNumericalException.java:98)
    at freemarker.core.StringBuiltins$numberBI.calculateResult(StringBuiltins.java:223)
    at freemarker.core.StringBuiltins$StringBuiltIn._eval(StringBuiltins.java:87)
    at freemarker.core.Expression.eval(Expression.java:111)
    at freemarker.core.EvalUtil.compare(EvalUtil.java:147)
    at freemarker.core.ComparisonExpression.evalToBoolean(ComparisonExpression.java:103)
    at freemarker.core.AndExpression.evalToBoolean(AndExpression.java:68)
    at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:84)
    at freemarker.core.Environment.visit(Environment.java:265)
    at freemarker.core.MixedContent.accept(MixedContent.java:93)
    at freemarker.core.Environment.visitByHiddingParent(Environment.java:286)
    at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:193)
    at freemarker.core.Environment.visitIteratorBlock(Environment.java:509)
    at freemarker.core.IteratorBlock.accept(IteratorBlock.java:103)
    at freemarker.core.Environment.visitByHiddingParent(Environment.java:286)
    at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:86)
    at freemarker.core.Environment.visit(Environment.java:265)
    at freemarker.core.MixedContent.accept(MixedContent.java:93)
    at freemarker.core.Environment.visit(Environment.java:265)
    at freemarker.core.Environment.process(Environment.java:243)
    at freemarker.template.Template.process(Template.java:277)
    at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:367)
    at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:284)
    at org.spri

 

 

二:错误代码

<select name="warehouseClassId">
                                            <option value="">选择仓库类别</option>
                                         <#if (warehouseClassDTOList?exists && warehouseClassDTOList?size>0) >
                                                <#list warehouseClassDTOList as r>
                                            <option value="${r.id!}" <#if warehouseClassId??&&r.id== (warehouseClassId?number)>selected</#if>>${r.name!}</option>
                                                </#list>
                                        </#if>
                                        </select>

 

三、解决方法

     warehouseClassId从后端传过来是字符串,r.id是Long型,故报错,所以上网查了一下怎样将字符串转成数字,没错,就像上面的warehouseClassId?number一样,但还是没卵用还是报错,不知道为啥。。。

    所以我决定投机取巧 将r.id变成 (r.id)?string,即将数字转成字符串,然而成功了。。。。。。

    我还能说什么。。。。

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值