日期:2014-05-17  浏览次数:20733 次

JSF中javax.faces.el.PropertyNotFoundException: Error getting property的问题
先贴一下代码吧。jsp页面中代码如下:
Java code

<h:outputText value="掌握外语语种:" />
<h:selectManyListbox value="#{ResumeBean.language}">
     <f:selectItems value="#{ResumeBean.languageMap}" />
</h:selectManyListbox>


这里是想使用托管的bean给前台注入值。后台的java代码如下:
Java code

private static Map<String, String> languageMap = null;

    public static Map<String, String> getLanguageMap() {
        languageMap = new LinkedHashMap<String, String>();
        languageMap.put("英语", "英语");
        languageMap.put("日语", "日语");
        languageMap.put("俄语", "俄语");
        languageMap.put("德语", "德语");
        return languageMap;
    }

    public static void setLanguageMap(Map<String, String> languageMap) {
        ResumeBean.languageMap = languageMap;
    }


但是在运行jsf页面的时候,总是报错,检查了很久,不知道什么原因。错误代码如下:
Java code

严重: Servlet.service() for servlet jsp threw exception
javax.faces.el.PropertyNotFoundException: Error getting property 'languageMap' from bean of type cn.test.ResumeBean
    at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:107)
    at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:167)
    at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:151)
    at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243)
    at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:173)
    at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
    at javax.faces.component.UISelectItems.getValue(UISelectItems.java:110)
    at com.sun.faces.util.Util.getSelectItems(Util.java:614)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:488)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:465)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:430)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:712)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:443)
    at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:233)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:693)
    at javax.faces.webapp.UIComponentTag.encodeChildren(UIComponentTag.java:600)
    at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:537)
    at com.sun.faces.taglib.html_basic.PanelGridTag.doEndTag(PanelGridTag.java:460)
    at org.apache.jsp.pages.resume_jsp._jspx_meth_h_005fpanelGrid_005f0(resume_jsp.java:261)
    at org.apache.jsp.pages.resume_jsp._jspx_meth_h_005fform_005f0(resume_jsp.java:180)
    at org.apache.jsp.pages.resume_jsp._jspx_meth_f_005fview_005f0(resume_jsp.java:143)
    at org.apache.jsp.pages.resume_jsp._jspService(resume_jsp.java:108)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
    at javax