2017-07-28 4 views
0

Ich bin eine Web-Anwendung in Java 8. Ich verwende Maven schreiben, und ich eingeschlossen, die Abhängigkeiten in Bezug auf Frühling Webflow in meinem Projekt:Wie kann ich meine Webanwendung über web.xml "informieren", dass ich eine Konfigurationsdatei für Spring Webflow habe?

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

Ich benutze Formular-basierte Authentifizierung und meine web.xml sieht wie folgt aus:

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

ich habe erstellt auch die Konfiguration für das Frühjahr webflows und ich seved es mit dem Namen "WEB-INF \ config \ spring-Webflow-config.xml" und es sieht wie folgt aus:

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

In dem obigen Code ich den Ordner/url-Muster, das ich für meine webflows

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

Die Frage ist, folgen wollen erklären, wie ich meine Web-Anwendung zu tun zu verwalten, dass es informieren ist eine Konfiguration bezüglich spring webflow?

Ich sah eine Menge von Beispielen und Übungen, aber für einigen lustigen Grund in keinen erklärt

a) dem Ordner jede Konfigurationsdatei gesetzt werden sollte, weder

b), was der Name ist, dass Die Konfigurationsdateien sollten, um von Spring Webflow Framework erkannt zu werden.

Falls Sie wissen, wie es möglich ist, meine Webanwendung über Spring Webflow zu informieren, lassen Sie es mich bitte wissen.

Vielen Dank im Voraus.

Antwort

0

Es ist nicht besonders ganz gleich, wo Sie die Webflow Konfigurationsdatei setzen, sagen Sie nur das Frühling 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> 

Und es kann nicht offensichtlich sein, aber es ist der Spring MVC-Setup, die durch beschrieben wird Dieser Abschnitt der offiziellen WebFlow-Dokumentation: http://docs.spring.io/spring-webflow/docs/current/reference/html/spring-mvc.html#spring-mvc-config-web.xml

Verwandte Themen