【问题标题】:JSF javax.servlet.ServletException: Method not found: class entityJSF javax.servlet.ServletException:找不到方法:类实体
【发布时间】:2017-05-15 01:31:45
【问题描述】:

我想知道如何从我的实体 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)

谢谢你的回答

编辑::

感谢您的解决方案

【问题讨论】:

  • 请发布消耗品类

标签: java jsf servlets jsf-2


【解决方案1】:

不要将 int 作为参数,而是尝试将 Integer 作为参数...原始 int 类解析为 int.class 而不是 Integer.class。

【讨论】:

  • "public String anystock(Integer value) {" 像这样,但它仍然是相同的错误消息。
猜你喜欢
  • 1970-01-01
  • 2017-02-15
  • 2023-03-28
  • 1970-01-01
  • 1970-01-01
  • 2015-08-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多