2017-07-28 108 views
0

我用Java編寫8. Web應用程序我使用Maven和我包括在我的項目有關的Webflow春天的依賴:如何通過web.xml「通知」我的web應用程序,我擁有關於Spring Webflow的配置文件?

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

我使用基於表單的認證和我的web.xml看起來像這樣:

<?xml version="1.0" encoding="UTF-8"?> 
    <web-app id="PROJECT" version="3.0" 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_3_0.xsd" 
     xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" 
     xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" xmlns:o="http://omnifaces.org/ui" 
     xmlns:of="http://omnifaces.org/functions"> 

     <display-name>PROJECT</display-name> 

    /* 
    * Somewhere here should I insert something in order to have 
    * my web application informed, that there is a spring-webflow-config.xml 
    * configuration file. How do I do this? 
    */ 

     <welcome-file-list> 
      <welcome-file>WEB-INF/firstPage.xhtml</welcome-file> 
     </welcome-file-list> 

     <security-constraint> 
      <display-name>Constraint</display-name> 
      <web-resource-collection> 
       <web-resource-name></web-resource-name> 
       <description /> 
       <url-pattern>/flows/*</url-pattern> 
      </web-resource-collection> 

      <auth-constraint> 
       <description /> 
       <role-name>ADMIN</role-name> 
       <role-name>USER</role-name> 
      </auth-constraint> 

     </security-constraint> 

     <login-config> 
      <auth-method>FORM</auth-method> 
      <realm-name>file</realm-name> 
      <form-login-config> 
       <form-login-page>WEB-INF/login.xhtml</form-login-page> 
       <form-error-page>WEB-INF/error.xhtml</form-error-page> 
      </form-login-config> 
     </login-config> 

     <security-role> 
      <description>Administration</description> 
      <role-name>ADMIN</role-name> 
     </security-role> 
     <security-role> 
      <description>User</description> 
      <role-name>USER</role-name> 
     </security-role> 

    </web-app> 

我也創建了春天webflows配置和我的名字 「WEB-INF \ config目錄\彈簧的Webflow-config.xml中」 seved它,它看起來像這樣:

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:webflow="http://www.springframework.org/schema/webflow-config" 

xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd 
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
    http://www.springframework.org/schema/webflow-config 
    http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd"> 


<mvc:annotation-driven /> 

<!-- Webflow Configuration --> 
<webflow:flow-executor id="flowExecutor" /> 

<webflow:flow-registry id="flowRegistry"> 
    <webflow:flow-location-pattern value="/WEB-INF/flows/*-flow/*-flow.xml" /> 
</webflow:flow-registry> 

<bean id="flowMappings" 
    class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"> 
    <property name="order" value="0" /> 
    <property name="flowRegistry" ref="flowRegistry" /> 
</bean> 

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

在上面的代碼,我宣佈的文件夾/ url-pattern的我想跟隨我的webflows

/WEB-INF/flows/*-flow/*-flow.xml

的問題是,如何管理通知我的web應用程序,有是關於spring webflow的配置?

我查閱了大量的實例和教程,但是對於一些有趣的原因,沒有人解釋

一)在哪個文件夾應該每個配置文件中說,無論

B)是什麼名稱配置文件應該有,以便從Spring Webflow框架中得到認可。

如果您知道如何「通知」我的web應用程序Spring Webflow,請告訴我。

預先感謝您。

回答

0

它並不特別無論你在哪裏把Webflow的配置文件,你只要告訴Spring的DispatcherServlet:

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

<servlet-mapping> 
    <servlet-name>Spring MVC Dispatcher</servlet-name> 
    <url-pattern>/</url-pattern> 
</servlet-mapping> 

而且這可能不是很明顯,但它是Spring MVC的設置,這是由描述官方WebFlow文檔的這一部分:http://docs.spring.io/spring-webflow/docs/current/reference/html/spring-mvc.html#spring-mvc-config-web.xml

相關問題