在托管bean上找不到JSF属性

时间:2014-02-17 13:59:47

标签: jsf jsf-2 primefaces managed-bean

我试图在我的JSF应用程序中创建一个menaged bean。

我不确定它是否与我的问题有关,但我使用的是primefaces 4.0及其中的一些主题。我用maven添加了我需要的所有jar文件。

Primefaces使用托管bean作为主题,但效果很好。

这是我的豆子:

package Beans;

@ManagedBean
@SessionScoped
public class QueryBean implements Serializable {

    private String name;

    public QueryBean() {
        name = "Maozturk";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}

在XHTML文件中,我试图像这样使用这个bean:

<h:outputText value="#{queryBean.name}" />

无论我试图访问名称变量,我都不能,我尝试@PostConstruct来给出一个初始值,同时我遇到了同样的问题。

这是我得到的错误:

  

SEVERE:servlet [Faces Servlet]的Servlet.service()与上下文有关   路径[/ RIA]抛出异常[/index2.xhtml @ 296,48   value =&#34;#{queryBean.name}&#34;:Property&#39; name&#39;在类型上找不到   Beans.QueryBean]与根本原因javax.el.PropertyNotFoundException:   财产名称&#39;在类型Beans.QueryBean上找不到   javax.el.BeanELResolver $ BeanProperties.get(BeanELResolver.java:229)     在   javax.el.BeanELResolver $ BeanProperties.access $ 400(BeanELResolver.java:206)     在javax.el.BeanELResolver.property(BeanELResolver.java:317)at   javax.el.BeanELResolver.getValue(BeanELResolver.java:85)at at   com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)     在   com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)     在org.apache.el.parser.AstValue.getValue(AstValue.java:183)at   org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)     在   com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)     在   javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)     在   javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)     在javax.faces.component.UIOutput.getValue(UIOutput.java:174)at   com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)     在   com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)     在   com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)     在   javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)     在   com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)     在   com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)     在   com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)     在   javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)     在   org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:70)     在   org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:57)     在   org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:204)     在   org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:121)     在   org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:58)     在   javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)     在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)     在javax.faces.render.Renderer.encodeChildren(Renderer.java:176)at   javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)     在   org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:70)     在   org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:57)     在   org.primefaces.component.dialog.DialogRenderer.encodeContent(DialogRenderer.java:184)     在   org.primefaces.component.dialog.DialogRenderer.encodeMarkup(DialogRenderer.java:113)     在   org.primefaces.component.dialog.DialogRenderer.encodeEnd(DialogRenderer.java:47)     在   javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)     在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)     在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)     在javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)     在   com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:461)     在   com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)     在   com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)     在com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)at   com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)     在javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)     在   org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)     在   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)     在   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)     在   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)     在   org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)     在   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)     在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)     在   org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)     在   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)     在   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)     在   org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)     在   org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:603)     在   org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:310)     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source)     在java.lang.Thread.run(未知来源)

这是我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>RIA</display-name>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>bluesky</param-value>
</context-param>
</web-app>

0 个答案:

没有答案