2014-01-16 9 views
1

스프링 mvc, 웹 플로우 및 프라임을 사용하여 샘플 프로젝트를 만들려고합니다. 여기 내 배치 설명자 (web.xml 파일)입니다 :스프링 웹 플로우 + MVC 리소스 매핑

<?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" id="WebApp_ID" version="3.0"> 
    <display-name>TestMVC</display-name> 
    <welcome-file-list> 
    <welcome-file>/app/testClasses</welcome-file> 
    </welcome-file-list> 

    <!-- Context parameters --> 
    <context-param> 
     <param-name>log4jConfigLocation</param-name> 
     <param-value>log4j.properties</param-value> 
    </context-param> 
    <context-param> 
     <param-name>log4jExposeWebAppRoot</param-name> 
     <param-value>false</param-value> 
    </context-param> 

    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/applicationContext.xml</param-value> 
    </context-param> 


     <!-- Logging -->  
    <listener> 
     <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> 
    </listener> 
    <!-- Appcontext listener --> 
    <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 

    <listener> 
     <listener-class>com.sun.faces.config.ConfigureListener</listener-class> 
    </listener> 

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

    <context-param> 
     <param-name>javax.faces.PROJECT_STAGE</param-name> 
     <param-value>Development</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> 
     <param-value>1</param-value> 
    </context-param> 

    <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> 
     <servlet-name>appServlet</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <init-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value>/WEB-INF/servlet-context.xml</param-value> 
     </init-param> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>appServlet</servlet-name> 
     <url-pattern>/app/*</url-pattern> 
    </servlet-mapping> 


</web-app> 

MVC 서블릿 컨텍스트 :

<?xml version="1.0" encoding="UTF-8"?> 

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:jaxws="http://cxf.apache.org/jaxws" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:oxm="http://www.springframework.org/schema/oxm" 
    xmlns:task="http://www.springframework.org/schema/task" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:webflow-config="http://www.springframework.org/schema/webflow-config" 
    xmlns:faces="http://www.springframework.org/schema/faces" 
    xmlns:p="http://www.springframework.org/schema/p" 
    xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd 
     http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd 
     http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.2.xsd 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd 
     http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.2.xsd 
     http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> 


    <bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" /> 
    <webflow-config:flow-executor id="flowExecutor"> 
     <webflow-config:flow-execution-listeners> 
      <webflow-config:listener ref="facesContextListener"/> 
     </webflow-config:flow-execution-listeners> 
    </webflow-config:flow-executor> 

    <faces:flow-builder-services id="flowBuilderServices"/> 

    <webflow-config:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows"> 
     <webflow-config:flow-location-pattern value="/**/flow.xml"/> 
    </webflow-config:flow-registry> 

    <mvc:annotation-driven /> 
    <mvc:resources location="/, classpath:/META-INF/resources/primefaces/, classpath:/META-INF/resources/primefaces-aristo/" mapping="/javax.faces.resource/**"/> 

    <context:component-scan base-package="ru.test.controller" /> 

    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"> 
     <property name="flowRegistry" ref="flowRegistry" /> 
    </bean> 

    <bean class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
     <property name="viewClass" value="org.springframework.faces.mvc.JsfView" /> 
     <property name="prefix" value="/WEB-INF/views/" /> 
     <property name="suffix" value=".xhtml" /> 
    </bean> 

    <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter"> 
     <property name="flowExecutor" ref="flowExecutor" /> 
    </bean> 

    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource" p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application" p:fallbackToSystemLocale="false" /> 
</beans> 

내가 가진 문제 - 그것은 잘 만드는 것입니다 같은 매핑 :

<mvc:resources location="/, classpath:/META-INF/resources/primefaces/, classpath:/META-INF/resources/primefaces-aristo/" mapping="/javax.faces.resource/**"/> 

MVC 서블릿 컨텍스트에서 또는 뭔가 잘못하고 있어요? 책 "Pro SPRING 3"의 예제에는 그런 매핑이 없지만이를 제거하면 DispatcherServlet의 ".../javax.faces.resource/theme.css"에 대한 매핑이없는 것과 같은 오류가 표시됩니다. 곧. 어쨌든 primefaces-aristo/images에서 이미지를 보지 못하기 때문에 맵핑을 추가하는 방법이 잘못되었다고 생각합니다. 라이브러리의

버전은 다음과 같습니다 봄 얼굴과 webflow : 2.3.0.RELEASE 봄 webmvc : 3.2.3.RELEASE Primefaces : 4.0 JSF-API 및 JSF-IMPL : 2.0.11

감사합니다 미리!

업데이트 : 직접 답변을 찾았습니다. 내가 사용하는 방법은 잘못, 태그 MVC입니다 : 자원이 로컬 리소스 매핑에 사용되며 하나가 MVC 서블릿 컨텍스트에

<faces:resources/> 

를 추가 할 필요가 JSF 자원을 매핑 할 수 있습니다.

답변

0
used pom.xml 

    <dependency> 
    <groupId>org.springframework.webflow</groupId> 
    <artifactId>spring-js</artifactId> 
    <version>2.4.0.RELEASE</version> 
    </dependency> 



and 

    <mvc:resources mapping="/web-resources/**/" location="/"/>