2017-07-28 5 views
0

Je vous écris une application web en Java 8. J'utilise Maven et j'inclus les dépendances concernant Spring Webflow dans mon projet:Comment puis-je "informer" mon application web via web.xml que j'ai un fichier de configuration concernant Spring Webflow?

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

J'utilise l'authentification basée sur la forme et mon web.xml ressemble à ceci:

<?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> 

J'ai aussi créé la configuration pour webflows de printemps et je l'ai seved avec le nom "WEB-INF \ config \ printemps-webflow-config.xml" et il ressemble à ceci:

<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> 

Dans le code ci-dessus, je déclare le dossier/url-pattern Je veux suivre mes webflows

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

La question est, comment puis-je parviens à informer mon application Web que est une configuration concernant spring webflow?

Je regardai beaucoup d'exemples et des tutoriels, mais pour une Noone raison drôle explique

a) dans lequel le dossier doit chaque fichier de configuration être mis, ni

b) quel est le nom que les fichiers de configuration doivent avoir, afin d'être reconnus à partir du framework Spring Webflow.

Dans le cas où vous savez comment est-il possible d '"informer" mon application Web sur Spring Webflow, s'il vous plaît faites le moi savoir.

Merci d'avance.

Répondre

0

Il n'a pas particulièrement importe où vous placez le fichier de configuration de webflow, vous venez de dire au printemps DispatcherServlet: configuration

<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> 

Et il ne peut pas être évident, mais il est le Spring MVC, qui est décrit par cette section de la documentation WebFlow officielle: http://docs.spring.io/spring-webflow/docs/current/reference/html/spring-mvc.html#spring-mvc-config-web.xml