Spring 3 / JSF 2 / javax.faces.resource没有加载correclt

时间:2012-06-25 12:06:56

标签: spring jsf richfaces

我正在尝试建立一个新项目,包括

  • spring 3.1.1.RELEASE
  • webflow 2.3.1.RELEASE
  • richfaces 4.2.2.Final
  • jsf com.sun.faces:jsf-api:2.1.7
  • jstl javax.servlet:jstl:1.2

一切正常,但javax.faces.resource / *似乎无法访问。

  

获取http://feelgood-inc.net:8080/jrisk-web-ui/ * / javax.faces.resource / richfaces.js 404(未找到)

我怀疑问题来自“javax.faces”前面的“/ /”。当我删除/ 时,它可以正常工作。

  

GET http://feelgood-inc.net:8080/jrisk-web-ui/javax.faces.resource/richfaces.js有效!

有没有人遇到过这个问题?我无法摆脱每个javax.faces.resource调用前面的额外“/ *”....

my faces-config.xml

<faces-config xmlns="http://java.sun.com/xml/ns/javaee" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
       http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
version="2.1">

</faces-config>

我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<!-- The Bootstrap listener to start up and shut down Spring's root WebApplicationContext. It is registered to Servlet Container -->
<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>0</load-on-startup>
</servlet>

<servlet>
    <servlet-name>Spring MVC Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>Spring MVC Servlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
</servlet-mapping>

<context-param> 
    <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
    <param-value>*.xhtml</param-value>
</context-param>

我的春季mvc配置

    <beans:bean name="richfacesResourceHandler"      
 class="org.springframework.faces.webflow.JsfResourceRequestHandler" />

<beans:bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <beans:property name="order" value="0" />
    <beans:property name="mappings">
        <beans:value>
            /javax.faces.resource/*=richfacesResourceHandler
            /rfRes/**=richfacesResourceHandler
        </beans:value>
    </beans:property>
</beans:bean>

<faces:resources />

2 个答案:

答案 0 :(得分:1)

如何将2.1更改为2.0?

<faces-config xmlns="http://java.sun.com/xml/ns/javaee" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
       http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0">
</faces-config>

答案 1 :(得分:0)