struts2 tag if NumberFormatException
2012-09-17 10:52
155 查看
http://www.4ucode.com/Study/Topic/367889————————————————————————————————————————————————————————
今天用struts2的if标签作一个判断,死活到不了if里面,代码如下:
<s:if test="namePinYin == 'a'">hello</s:if>
页面也不报错,而且也测试了namePinYin的确等于a
后来发现服务器报了个NumberFormatException,信息如下:
Caught an exception while evaluating expression 'namePinYin == 'a'' against value stack
java.lang.NumberFormatException: For input string: "a"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
google了一下,发现问题其实很简单,namePinYin是个字符串,test的时候需要这样写:
<s:if test='namePinYin == "a"'>hello</s:if>
照这样看,单引号可能会用于比较数字类型,详细可以查看一下官方的faq:
http://struts.apache.org/2.x/docs/why-wont-the-if-tag-evaluate-a-one-char-string.html
<s:if test="aStringProperty == 'A'">
Why doesn't this work when myString is equal to A?
</s:if>
<s:if test='aStringProperty == "A"'>
This works!
</s:if>
今天用struts2的if标签作一个判断,死活到不了if里面,代码如下:
<s:if test="namePinYin == 'a'">hello</s:if>
页面也不报错,而且也测试了namePinYin的确等于a
后来发现服务器报了个NumberFormatException,信息如下:
Caught an exception while evaluating expression 'namePinYin == 'a'' against value stack
java.lang.NumberFormatException: For input string: "a"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
google了一下,发现问题其实很简单,namePinYin是个字符串,test的时候需要这样写:
<s:if test='namePinYin == "a"'>hello</s:if>
照这样看,单引号可能会用于比较数字类型,详细可以查看一下官方的faq:
http://struts.apache.org/2.x/docs/why-wont-the-if-tag-evaluate-a-one-char-string.html
<s:if test="aStringProperty == 'A'">
Why doesn't this work when myString is equal to A?
</s:if>
<s:if test='aStringProperty == "A"'>
This works!
</s:if>
相关文章推荐
- struts2,hibernate java.lang.NumberFormatException: For input string 错误
- Mybatis if语句对比string时提示NumberFormatException
- Struts2请求加上时间戳出现java.lang.NumberFormatException: For input string:
- Mybatis的if test字符串比较 报NumberFormatException错误
- org.apache.jasper.JasperException: xxxx.jsp(118,24) Attribute style invalid for tag formatNumber according to TLD
- Struts2访问验证码异常解决OgnlValueStack:64 - ..java.lang.NumberFormatException: For input string: "1494056190
- NumberFormatException in setTag(int key, Object tag) method
- Struts2请求加上时间戳出现java.lang.NumberFormatException
- org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 18
- java.lang.NumberFormatException: For input string: "9004@19004" 的解决办法
- NumberFormatException: For input string异常处理
- myBatis test 表达式抛出 NumberFormatException 错误的解决办法
- NumberFormatException
- ClassFormatException: Invalid byte tag in constant pool
- 第一次访问本机上的spring-boot报错:java.lang.NumberFormatException: For input string: "index"
- java中的java.lang.NumberFormatException异常
- weblogic集群无法启动,提示java.lang.NumberFormatException
- 记录常遇到的异常 (NullPointerException,NumberFormatException,ClassCastException...)
- 常见错误:java.lang.NumberFormatException: For input string: "6 "
- java.lang.NumberFormatException: For input string:"filesId"