JSF javax.servlet.ServletException:找不到方法:class 实体
JSF javax.servlet.ServletException: Method not found: class entity
我想知道如何从我的实体 consumable.java 调用这个函数 anystock 并在 xhtml 上使用它。
public String anystock(int value) {
String result = null;
if (value==0)
{
result="Please fill the stock of this device";
}
else if (value<5)
{
result="The stock will be empty ";
}
return result;
}
Xhtml:
</p:column>
<p:column headerText="message" >
<h:outputText value="#{consumable.anystock(consumable.stock)}"/>
</p:column>
这里工作正常,我也收到了一些信息:
<p:column headerText="stock" sortBy="#{consumable.stock}" filterBy="#{consumable.stock}">
<h:outputText value="#{consumable.stock}"/>
</p:column>
错误代码:
javax.servlet.ServletException: Method not found: class entity.Consumable.anystock(java.lang.Integer)
谢谢您的回答
编辑::
感谢 prashant 的解决方案
而不是将 int 作为参数尝试将 Integer 作为参数...Class 原始 int 解析为 int.class 而不是 Integer.class.
我想知道如何从我的实体 consumable.java 调用这个函数 anystock 并在 xhtml 上使用它。
public String anystock(int value) {
String result = null;
if (value==0)
{
result="Please fill the stock of this device";
}
else if (value<5)
{
result="The stock will be empty ";
}
return result;
}
Xhtml:
</p:column>
<p:column headerText="message" >
<h:outputText value="#{consumable.anystock(consumable.stock)}"/>
</p:column>
这里工作正常,我也收到了一些信息:
<p:column headerText="stock" sortBy="#{consumable.stock}" filterBy="#{consumable.stock}">
<h:outputText value="#{consumable.stock}"/>
</p:column>
错误代码:
javax.servlet.ServletException: Method not found: class entity.Consumable.anystock(java.lang.Integer)
谢谢您的回答
编辑::
感谢 prashant 的解决方案
而不是将 int 作为参数尝试将 Integer 作为参数...Class 原始 int 解析为 int.class 而不是 Integer.class.