2
我正在嘗試使用註釋(不使用faces-config.xml來定義託管bean)的Spring 3和JSF 2的簡單集成,米卡住了一個錯誤。Spring-JSF2集成:目標無法訪問,標識符'customerBean'解析爲空
的錯誤是:
javax.el.PropertyNotFoundException: /customer/add.xhtml @11,70 value="#{customerBean.firstName}": Target Unreachable, identifier 'customerBean' resolved to null
這是網頁:add.xhtml
<h:body>
<h:form>
<label>First Name <h:inputText value="#{customerBean.firstName}" /></label><br />
<label>Last Name <h:inputText value="#{customerBean.lastName}" /></label><br />
<label>Email <h:inputText value="#{customerBean.email}" /></label><br />
<h:commandButton value="Add" action="#{customerBean.add}" />
</h:form>
</h:body>
這是豆:CustomerBean.java
package com.devworkzph.customer.sample.bean;
@Component
@Qualifier("customerBean")
@SessionScoped
public class CustomerBean implements Serializable{
private String firstName;
private String lastName;
private String email;
public String add(){
// code
}
//getters and setters
}
這是一個我的一部分applicationContext.xml
<context:annotation-config />
<context:component-scan base-package="com.devworkzph.customer.sample" />
這是我的web.xml的一部分
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<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>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
有誰知道我在做什麼錯在這裏?
謝謝!