1

我得到一个例外

javax.el.PropertyNotFoundException: Property 'printIDs' not found on type pl.com.pir.beans.SelectedItemBean
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:237)
at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:214)
at javax.el.BeanELResolver.property(BeanELResolver.java:325)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:85)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:217)
at com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:157)
at com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:77)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:437)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

但是在我的代码中,这个方法被注释了,我试图清除网络浏览器捕获和cookies,在代码中搜索'printIDs'字符串,并且所有的出现也被注释了,我查看了face-config.xml和web.xml,删除了webapp在 tomcat webapps 目录中,即使重新启动我的电脑,也没有任何帮助。

        <!-- MENU GENERATOR -->
    <h:panelGroup layout="block" id="produktMenu">
            <o:dataTable value="#{productBean.productList}" var="produkt" pageSize="10"
                         style="margin-top: 15px; width: 100%; height: 420px;">
                         <o:multipleRowSelection rowDatas="#{productBean.list}" style="background: #a4aec5; color: white;" />
            <o:columnReordering />
            <f:facet name="columnMenu">
                <o:columnMenu />
            </f:facet>

            <o:column header="Kategoria" width="7%"
                sortingExpression="#{produkt.kategoria}"
                bodyStyle="padding-left: 5px; padding-right: 5px;"
                headerStyle="text-align: left; padding-left: 5px; padding-right: 5px;">
                <f:facet name="subHeader">
                    <o:dropDownFieldFilter maxlength="4" customValueAllowed="false" />
                </f:facet>
                <h:outputText value="#{produkt.kategoria}" />
            </o:column>

            <o:selectionColumn style="width: 6%;" sortable="true"
                header="Selection">
                <f:facet name="header">
                    <o:selectAllCheckbox />
                </f:facet>
            </o:selectionColumn>
            <f:facet name="below">
                    <o:dataTablePaginator id="paginator" />
                </f:facet>
                <o:column id="symbolCol1" sortingExpression="#{produkt.symbol}">
                    <f:facet name="header">
                        Symbol
                    </f:facet>
                    <h:outputText value="#{produkt.symbol}" />
                </o:column>
                <o:column id="opisCol1" sortingExpression="#{produkt.opis}">
                    <f:facet name="header">
                        Opis
                    </f:facet>
                    <h:outputText value="#{produkt.opis}" />
                </o:column>
                <o:column id="cenaCol1" sortingExpression="#{produkt.cena}">
                    <f:facet name="header">
                        Cena
                    </f:facet>
                    <h:outputText value="#{produkt.cena}" />
                </o:column>
            </o:dataTable>

    </h:panelGroup>
    <h:commandButton value="Dodaj" action="#{selectedItemBean.submit}" />

    <o:dataTable value="#{productBean.list}" var="l" id="resultTable">
        <o:column id="resultSumbolCol" sortingExpression="#{l.symbol}">
            <f:facet name="header">
                        Symbol
                    </f:facet>


            <h:outputText value="#{l.symbol}" />
        </o:column>
        <o:column id="resultOpisCol" sortingExpression="#{l.opis}">
            <f:facet name="header">
                        Opis
                    </f:facet>
            <h:outputText value="#{l.opis}" />
        </o:column>
        <o:column id="resultCenaCol" sortingExpression="#{l.cena}">
            <f:facet name="header">
                        Cena
                    </f:facet>
            <h:outputText value="#{l.cena}" />
        </o:column>
    </o:dataTable>

SelectedItemBean 来源:

    public String submit() {
    for (Map.Entry<Integer, Boolean> entry : selectedIDs.entrySet()) {
        if (entry.getValue() == true) {
            System.out.println("id: " + entry.getKey() + ", "
                    + entry.getValue());
            id.add(entry.getKey());
        }
    }
    System.out.println("SelectedItemBean.submit() --> " + id.size());
    return "selected";
}

public String printIDs() {
    int i = 0;
    if (id.isEmpty())
        return null;
    System.out.println("printIDs <--");
    Iterator<Integer> it = id.iterator();
    while (it.hasNext()) {
        i++;
        System.out.println(it.next());
    }
    System.out.println("suma produktow: " + i + "\nprintIDs -->");
    pb = new ProductBean();
    StringParse sp = new StringParse();
    idList = sp.prepareInStatement(id);
    try {
        list = pb.getProductByID(idList, 2);
        suma = cumputeCosts(list);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return "TESTprintIDs";
}

为什么我不断收到此异常?

4

2 回答 2

3

您没有显示您的注释代码,但我猜您使用了经典的 xml 注释

<!--  ...   -->

我必须说,默认情况下 EL 即使在注释中也会执行。您可以使用以下两种解决方案之一来解决此问题:

首先,您可以通过添加以下内容来全局禁用评论中的 EL 解析:

<context-param>
  <param-name>facelets.SKIP_COMMENTS</param-name>
  <param-value>true</param-value>
</context-param>

在你的web.xml文件中。

另一种解决方案是将您的评论包含在ui:remove标签中。

于 2013-02-06T10:25:12.017 回答
2

SelectedItemBean应该有该字段的访问器printIDs

public class SelectedItemBean{
    private String printIDs;

    private getPrintIDs(){
      return printIds;
    }
}

表达式语言使用 getter 方法进行属性解析。

您可以通过以下方式更改现有代码:

public String getPrintIDs() { //Notice new signature
    int i = 0;
    if (id.isEmpty())
        return null;
    System.out.println("printIDs <--");
    Iterator<Integer> it = id.iterator();
    while (it.hasNext()) {
        i++;
        System.out.println(it.next());
    }
    System.out.println("suma produktow: " + i + "\nprintIDs -->");
    pb = new ProductBean();
    StringParse sp = new StringParse();
    idList = sp.prepareInStatement(id);
    try {
        list = pb.getProductByID(idList, 2);
        suma = cumputeCosts(list);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return "TESTprintIDs";
}
于 2013-02-06T10:17:36.390 回答