【问题标题】:Spring 3 / JSF 2 / javax.faces.resource not correclt loadedSpring 3 / JSF 2 / javax.faces.resource 未正确加载
【发布时间】:2012-06-25 12:06:55
【问题描述】:

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

  • 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/* 似乎无法访问。

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

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

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

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

我的面孔-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>

我的spring 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 />

【问题讨论】:

  • 看起来是某种错误,试试这个 /jrisk-web-ui/* 用于 Spring MVC Servlet。 link

标签: spring jsf richfaces


【解决方案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>

【讨论】:

    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 2012-08-06
      • 1970-01-01
      • 2012-06-30
      • 2014-07-08
      • 2013-10-26
      • 1970-01-01
      • 2019-06-07
      • 2011-11-20
      • 1970-01-01
      相关资源
      最近更新 更多