问题描述
我在JBoss 7上使用的JSF 2.0具有质数.在代码的某些部分,我具有以下内容:
I'm using JSF 2.0 with primefaces over JBoss 7. In some part of the code, I have the following:
public void setItemValue(int value) {
this.value = value;
}
以及在xhtml中:
<p:commandButton ajax="true" value="Button" update="@form"
action="#{bean.setItemValue(1)}"/>
问题是,当我单击按钮时,我得到一个javax.el.MethodNotFoundException
,说setItemValue(java.lang.Long)
不存在.当然不是,它应该是int或Integer值!有人看到过这个问题吗?除了改变我的接收方法,还有其他选择吗?谢谢!
The problem is, when I click the button, I get an javax.el.MethodNotFoundException
, saying that setItemValue(java.lang.Long)
doesn't exists. Off course it doesn't, it should be a int or Integer value! Anyone has seen this problem? there is any alternative other than changing my method to receive a long? Thanks!
编辑:刚刚下载了JBoss 7.2的SNAPSHOT,它可以正常运行.看起来像是JBoss 7.1.1的错误:(
EDIT: Just downloaded the SNAPSHOT of JBoss 7.2, and it works fine on it. Looks like its a bug of JBoss 7.1.1 :(
推荐答案
操作的方法表达式类型为
The method expression type for action is
字符串action()
String action()
所以使用
public String setItemValue(Integer value) {
this.value = value;
return null;
}
另请参阅:
更新您需要将Servlet版本声明为3.0,以充分利用EL 2.2,例如传递参数.为此,将web.xml中的web-app元素更改为此:
UPDATEYou need to declare the Servlet version as 3.0 to take full advantage of the EL 2.2 such as passing the parameter. For that change your web-app element in your web.xml to this:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"
version="3.0">
这篇关于EL Expression解析整数,只要长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!