Getting started with Spring Web Flow 2.0

Source: Internet
Author: User
Tags unique id

Once you have configured the spring Web MVC environment, you can then add the Spring Web Flow 2.0 configuration to it. However, to understand the configuration of Spring Web Flow 2.0, you must first understand the relevant theoretical knowledge.

Flowregistry

Flowregistry is the warehouse where the flow is stored, and each XML document that defines the flow is parsed, and is assigned a unique ID and stored in the Flowresigtry as a Flowdefinition object. The Flowregistry configuration can be referred to listing 8.

Description

The XML configuration element in the following example manifest uses the Webflow namespace by default, which is also the namespace used by Spring Web flow, see the Webflow-config.xml file later in the tutorial to learn more about Webflow namespaces.

Listing 8 Flowregistry Configuration

<webflow:flow-registry id= "Flowregistry" >

<webflow:flow-location path= "/web-inf/flows/shopping.xml" id= "shopping"/>

</webflow:flow-registry>

Each flow must have an ID to identify it, and if omitted in the configuration, the flow default ID will be the name of the definition file to remove the string from the suffix.

Flowexecutor

Flowexecutor is a core interface of Spring Web flow, which starts a flow through this interface. From a configuration point of view, the default behavior of Spring Web flow is sufficient as long as it is guaranteed to have a flowexecutor. The default configuration is listed in Listing 9.

Listing 9 Flowexecutor Configuration

<webflow:flow-executor id= "Flowexecutor"/>

Which flow has been executed?

There may be more than one flow registered in Flowregistry, but as described earlier, each flow will have an ID, no configuration, and a default value, Flowexecutor is to find the flow to execute by ID. As for this ID, it is to be specified by the user. In the default configuration, if the client sends the following URL request:

http://localhost:8080/CartApp/spring/shopping

From the point of view of Spring Web flow, this URL means that the customer wants to execute a flow with an ID of "shopping", and then a flow called "shopping" is found in the Flowregistry, by Flowexecut Or is responsible for execution.

How does spring Web flow integrate with spring Web MVC?

Requests sent by the client are first received by the servlet container (in this tutorial example, Tomcat), the servlet container finds the appropriate application (Cartapp in this tutorial), and then finds a servlet that matches the mapping criteria according to the Web.xml configuration. The servlet that handles the request in spring Web MVC is Dispatcherservlet, and if the requested path satisfies the dispatcherservlet mapping condition, Dispatcherservlet will find the spring IoC tolerance All of the handlermapping in the handlermapping process the request according to the best matching handler (usually controller, the controller). When the Controller is finished, the name of the view is generally returned, and the view is returned to the client according to the Dispatcherservlet's name.

After figuring out how the spring Web MVC processes the request, you can basically understand the configuration needed to consolidate spring web MVC and Spring Web flow. To make a request for a client become a request to execute a flow, resolve the following issues:

The handler (or controller) that is responsible for handling the flow request needs to be configured in a handlermapping

The handler (or controller) is responsible for starting the specified flow

The views that are involved in the flow execution, and after the execution is completed, should be presented to the client

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.