Spring MVC - Web Flow Controller

I have a j2ee application developed using spring framework and spring web stream. Currently, all my URL requests go through the web stream. I want to be able to choose whether to direct it to Web Flow or a regular spring mvc controller. I do not know how to direct it to user controllers. How to do it?

I tried this in my web.xml but I cannot direct it to the bean controller specified in mytest2-servlet.xml

<servlet> <servlet-name>mytest</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet </servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value></param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet> <servlet-name>mytest2</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet </servlet-class> <init-param> <param-name>contextConfigLocation2</param-name> <param-value></param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mytest</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>mytest2</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/web-application-config.xml </param-value> </context-param> <context-param> <param-name>contextConfigLocation2</param-name> <param-value> /WEB-INF/mytest2-servlet.xml </param-value> </context-param> 
+4
source share
3 answers

Try in final condition

 <end-state id="exit" view="externalRedirect:controllerURL" /> 

where "controllerURL" is the URL your controller is listening on /

+1
source

The easiest way to combine both Web streams and simple Spring MVC controllers is to simply register simple controllers in URLs outside of any of your stream paths.

For example, here are some excerpts from our configuration files downloaded from web.xml single instance of DispatchServlet :

 <!-- Simple URL-view mapping without controller (or flow) --> <mvc:view-controller path="/selectLanguage" view-name="selectLanguage"/> <!-- Maps request paths to flows in the flowRegistry; eg a path of /hotels/booking looks for a flow with id "hotels/booking". --> <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping" p:order="-1"> <property name="flowRegistry" ref="flowRegistry" /> <property name="interceptors"> <list> <!-- for each flow, if a param lang=xx is added, switch locales --> <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="lang"/> </list> </property> </bean> <!-- The registry of executable flow definitions --> <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF"> <!-- Flows created from all -flow.xml files, with the flow ID being the path name --> <webflow:flow-location-pattern value="/**/*-flow.xml" /> </webflow:flow-registry> 

Thus, WebFlow will register all URL paths that correspond to the WEB-INF / ** / something-flow.xml file, and all other URL paths, such as /selectLanguage above , can be processed by a regular controller.

+1
source

write dispatcher-sevlet.xml or a configuration file, write a separate configuration file (for convenience) for Spring Streams simply import files into dispatcher-servlet.xml.

0
source

Source: https://habr.com/ru/post/1298965/


All Articles