2017-07-28 32 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

相关问题