JSF spring集成错误



我想集成JSF与spring。当我在faces配置文件中插入应用程序标签并在web.xml文件中使用上下文加载器侦听器时,它显示"请求的资源(/SampleWeb/faces/registration.xhtml)不可用"。这是我的faces配置文件:

<faces-config
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">
    <application>
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
    </application>
    <managed-bean>
        <managed-bean-name>empbean</managed-bean-name>
        <managed-bean-class>com.java.EmployeeBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
            <property-name>employeeBo</property-name>
            <value>#{employeeBo}</value>
        </managed-property>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>employeeBo</managed-bean-name>
        <managed-bean-class>com.java.EmployeeBOImpl</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
            <property-name>employeeDto</property-name>
            <value>#{employeeDto}</value>
        </managed-property>
    </managed-bean>
    <navigation-rule>
        <display-name>registration.xhtml</display-name>
        <from-view-id>/registration.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>register</from-outcome>
            <to-view-id>/welcome.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
</faces-config>

这是web.xml文件:

  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</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>/faces/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>

需要添加RequestContextListener作为侦听器每当您试图将Spring与JSF或Struts集成时

<listener> 
  <listener-class> 
     org.springframework.web.context.request.RequestContextListener
  </listener-class> 
</listener>

相关内容

  • 没有找到相关文章

最新更新