{"id":36272,"date":"2016-05-05T15:00:01","date_gmt":"2016-05-05T12:00:01","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=36272"},"modified":"2021-06-29T13:07:19","modified_gmt":"2021-06-29T10:07:19","slug":"spring-web-flow-tutorial","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/","title":{"rendered":"Spring Web Flow Tutorial"},"content":{"rendered":"<p>In this example, we will demonstrate what is Spring Web-Flow, what are its benefits, and how to configure it in a web application. In the <a href=\"https:\/\/examples.javacodegeeks.com\/enterprise-java\/spring\/mvc\/spring-mvc-login-example\/\">previous article<\/a>, we have demonstrated how Spring MVC can be configured.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-1-introduction\">1. Introduction<\/h2>\n<p>Spring MVC is a powerful framework that allows the user to configure and manage the flow of web-application in any possible way. However, sometimes the scenario may require be to have a more tight control over the flow of the application or to manage the possible ways to navigate through the application.<\/p>\n<p><a href=\"https:\/\/projects.spring.io\/spring-webflow\/\">Spring Web-Flow<\/a> helps in this kind of scenario by clearly defining the views and the transition between them. Web-Flow is itself based on top of <code>Spring MVC<\/code> and hence provides all the goodies of Spring MVC plus the added control over the transitions. Let&#8217;s look at how we can configure the Web-Flow for our applications:<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-2-project-set-up\">2. Project Set-Up<\/h2>\n<p>Let&#8217;s start by first setting up the project in Eclipse or any other you have in mind. We shall use Maven to setup our project. Open Eclipse and create a simple Maven project and check the skip archetype selection checkbox on the dialogue box that appears. Replace the content of the existing <code>pom.xml<\/code> with the one provided below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted brush:xml\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n  xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/maven-v4_0_0.xsd\"&gt;\n  &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n  &lt;groupId&gt;com.jcg.examples.springWebFlowExample&lt;\/groupId&gt;\n  &lt;artifactId&gt;SpringWebFlowExample&lt;\/artifactId&gt;\n  &lt;packaging&gt;war&lt;\/packaging&gt;\n  &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n  &lt;name&gt;SpringWebFlowExample&lt;\/name&gt;\n  &lt;url&gt;http:\/\/maven.apache.org&lt;\/url&gt;\n  &lt;dependencies&gt;\n    &lt;dependency&gt;\n      &lt;groupId&gt;junit&lt;\/groupId&gt;\n      &lt;artifactId&gt;junit&lt;\/artifactId&gt;\n      &lt;version&gt;3.8.1&lt;\/version&gt;\n      &lt;scope&gt;test&lt;\/scope&gt;\n    &lt;\/dependency&gt;\n     &lt;dependency&gt;\n        &lt;groupId&gt;org.springframework.webflow&lt;\/groupId&gt;\n        &lt;artifactId&gt;spring-webflow&lt;\/artifactId&gt;\n        &lt;version&gt;2.4.2.RELEASE&lt;\/version&gt;\n    &lt;\/dependency&gt;\n  &lt;\/dependencies&gt;\n  &lt;build&gt;\n    &lt;finalName&gt;SpringWebFlowExample&lt;\/finalName&gt;\n  &lt;\/build&gt;\n&lt;\/project&gt;\n\n<\/pre>\n<p>This will import the required JAR dependencies in the project. We can now start with the actual implementation of the Spring Web-Flow in our project.<\/p>\n<p>Our application will be a simple login based application. Upon hitting the URL for the first time, the user will directed to a login page.<br \/>The user enters his credentials and clicks on the login button.<br \/>If the password is correct the view transitions to success view or else the user is directed back to the login screen.<br \/>While this is a very basic scenario for the beginner users to understand, Spring Web-Flow is capable of handling many more complex scenarios.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-3-implementation\">3. Implementation<\/h2>\n<p>The implementation starts with the basic PoJo for login purposes which will hold the username and password.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>LoginBean.java<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted brush:java\">package com.jcg.examples.bean;\n\nimport java.io.Serializable;\n\npublic class LoginBean implements Serializable\n{\n\t\t\/**\n\t\t * \n\t\t *\/\n\t\tprivate static final long serialVersionUID = 1L;\n\n\t\tprivate String userName;\n\n\t\tprivate String password;\n\n\t\tpublic String getUserName()\n\t\t{\n\t\t\t\treturn userName;\n\t\t}\n\n\t\tpublic void setUserName(String userName)\n\t\t{\n\t\t\t\tthis.userName = userName;\n\t\t}\n\n\t\tpublic String getPassword()\n\t\t{\n\t\t\t\treturn password;\n\t\t}\n\n\t\tpublic void setPassword(String password)\n\t\t{\n\t\t\t\tthis.password = password;\n\t\t}\n\n\t\t@Override\n\t\tpublic String toString()\n\t\t{\n\t\t\t\treturn \"LoginBean [userName=\" + userName + \", password=\" + password + \"]\";\n\t\t}\n\n}\n\n<\/pre>\n<p>Next is the <code>Service<\/code> file which will authenticate the user. Based on the output of its <code>validateUser<\/code> method, web-flow will decide the view to be rendered. The Service class is marked with annotation to be picked up at run time by the Spring Bean Factory. For the sake of brevity, I have hard-coded the credentials in the source file itself.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>LoginService.java<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted brush:java\">package com.jcg.examples.service;\n\nimport org.springframework.stereotype.Service;\n\nimport com.jcg.examples.bean.LoginBean;\n\n@Service\npublic class LoginService\n{\n\t\tpublic String validateUser(LoginBean loginBean)\n\t\t{\n\t\t\t\tString userName = loginBean.getUserName();\n\t\t\t\tString password = loginBean.getPassword();\n\t\t\t\tif(userName.equals(\"Chandan\") &amp;&amp; password.equals(\"TestPassword\"))\n\t\t\t\t{\n\t\t\t\t\t\treturn \"true\";\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t\treturn \"false\";\n\t\t\t\t}\n\t\t}\n\t\t\n}\n\n<\/pre>\n<p>Now, we need to implement the define the flow. Flow is basically a cycle of events that will lead to completion of a single task in the context of the application. This cycle or flow will include multiple events and the user maybe made to navigate to and fro between various views, depending upon the choice he makes. Let&#8217;s have a look at the xml that we have to use for our application for flow navigation:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><span style=\"text-decoration: underline;\"><em>book-search-flow.xml<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;flow xmlns=\"http:\/\/www.springframework.org\/schema\/webflow\"\n\txmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n\txsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/webflow\nhttp:\/\/www.springframework.org\/schema\/webflow\/spring-webflow-2.4.xsd\"&gt;\n\n\t&lt;var name=\"loginBean\" class=\"com.jcg.examples.bean.LoginBean\" \/&gt;\n\t\n\t&lt;view-state id=\"displayLoginView\" view=\"jsp\/login.jsp\" model=\"loginBean\"&gt;\n\t\t&lt;transition on=\"performLogin\" to=\"performLoginAction\" \/&gt;\n\t&lt;\/view-state&gt;\n\n\t&lt;action-state id=\"performLoginAction\"&gt;\n\t\t&lt;evaluate expression=\"loginService.validateUser(loginBean)\" \/&gt;\n\n\t\t&lt;transition on=\"true\" to=\"displaySuccess\" \/&gt;\n\t\t&lt;transition on=\"false\" to=\"displayError\" \/&gt;\n\n\t&lt;\/action-state&gt;\n\t\n\t&lt;view-state id=\"displaySuccess\" view=\"jsp\/success.jsp\" model=\"loginBean\"\/&gt;\n\n\t&lt;view-state id=\"displayError\" view=\"jsp\/failure.jsp\" \/&gt;\n&lt;\/flow&gt;\n\n<\/pre>\n<p>The first view in the flow becomes the default view and hence, is shown when the URL for that particular <code>Flow<\/code> is hit for the first time. Once the user submits the flow moves to <code>action<\/code> tag to determine dynamically which view should be rendered. The <code>action directive<\/code> in turn uses the backing Service Bean we created earlier.<br \/>Also the view may have a backing Bean as we have in Spring MVC, which is defined by the <code>model<\/code> attribute. The view contain two important variables which tell the container, the event that has occurred and the current state of the application. These variables are <code>_eventId<\/code> and <code>_flowExecutionKey<\/code>. When coding for the view, the developer should not forget to include these variables in the view code.<\/p>\n<p>Now that the flow is ready we need to hook it up somewhere in the system, so that it can be picked up by the Spring Container.<\/p>\n<p><code>flow-definition.xml<\/code> file defines a <code>Flow-Executor<\/code> and a <code>Flow-Registry<\/code>. As the name indicates, the <code>Flow-Executor<\/code>, actually orchestrates the flow while it refers to <code>Flow-Registry<\/code> to determine the next action to be taken for the flow.<\/p>\n<p><code>FlowHandlerMapping<\/code> is responsible for creating the appropriate URLs for all the flows defined in the application.<br \/><code>FlowHandlerAdapter<\/code> encapsulates the actual flow and delegates the specific flows to be handled by the Spring Flow Controllers. We will include this file in the main spring configuration sheet so that our web-flow gets hooked into the main Spring Container and the requests are directed to the Flow Controllers.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>flow-definition.xml<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\n\txmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:flow=\"http:\/\/www.springframework.org\/schema\/webflow-config\"\n\txsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/webflow-config\nhttp:\/\/www.springframework.org\/schema\/webflow-config\/spring-webflow-config-2.4.xsd\nhttp:\/\/www.springframework.org\/schema\/beans\nhttp:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd\"&gt;\n\n\t&lt;bean class=\"org.springframework.webflow.mvc.servlet.FlowHandlerMapping\"&gt;\n\t\t&lt;property name=\"flowRegistry\" ref=\"bookSearchFlowRegistry\" \/&gt;\n\t&lt;\/bean&gt;\n\n\t&lt;bean class=\"org.springframework.webflow.mvc.servlet.FlowHandlerAdapter\"&gt;\n\t\t&lt;property name=\"flowExecutor\" ref=\"bookSearchFlowExecutor\" \/&gt;\n\t&lt;\/bean&gt;\n\n\t&lt;flow:flow-executor id=\"bookSearchFlowExecutor\" flow-registry=\"bookSearchFlowRegistry\" \/&gt;\n\n\t&lt;flow:flow-registry id=\"bookSearchFlowRegistry\"&gt;\n\t\t&lt;flow:flow-location id=\"bookSearchFlow\" path=\"\/flows\/book-search-flow.xml\" \/&gt;\n\t&lt;\/flow:flow-registry&gt;\n\n&lt;\/beans&gt;\n\n<\/pre>\n<p><code>spring-config.xml<\/code> contains the basic information for the spring container for tasks like rendering the views, bean declarations, annotation scanning etc. It also includes the <code>flow-definition.xml<\/code> file for the container to load its contents.[ulp id=&#8217;7POIYxRf1FUtPpmL&#8217;]<\/p>\n<p><span style=\"text-decoration: underline;\"><em>spring-config.xml<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\n\txmlns:context=\"http:\/\/www.springframework.org\/schema\/context\"\n\txmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:flow=\"http:\/\/www.springframework.org\/schema\/webflow-config\"\n\txsi:schemaLocation=\"\n\thttp:\/\/www.springframework.org\/schema\/webflow-config\n\thttp:\/\/www.springframework.org\/schema\/webflow-config\/spring-webflow-config-2.4.xsd\n   http:\/\/www.springframework.org\/schema\/beans\n   http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd\n   http:\/\/www.springframework.org\/schema\/context\n   http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd\"&gt;\n\n\t&lt;context:component-scan base-package=\"com.jcg.examples\" \/&gt;\n\n\t&lt;bean\n\t\tclass=\"org.springframework.web.servlet.view.InternalResourceViewResolver\"&gt;\n\t\t&lt;property name=\"prefix\" value=\"\/jsp\/\" \/&gt;\n\t\t&lt;property name=\"suffix\" value=\".jsp\" \/&gt;\n\t&lt;\/bean&gt;\n\t\n\t&lt;import resource=\"flow-definition.xml\"\/&gt;\n\t\n&lt;\/beans&gt;\n\n<\/pre>\n<p>The <code>web.xml<\/code> is similar to any spring mvc application. It starts the Spring container with the above xml and directs all the reuqests to the <code>DispatcherServlet<\/code>.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>web.xml<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted brush:xml\">&lt;!DOCTYPE web-app PUBLIC\n \"-\/\/Sun Microsystems, Inc.\/\/DTD Web Application 2.3\/\/EN\"\n \"http:\/\/java.sun.com\/dtd\/web-app_2_3.dtd\" &gt;\n\n&lt;web-app&gt;\n  &lt;display-name&gt;Spring-Flow Web-Application Example&lt;\/display-name&gt;\n  \n  &lt;servlet&gt;\n\t\t&lt;servlet-name&gt;springFlowApplication&lt;\/servlet-name&gt;\n\t\t&lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;\/servlet-class&gt;\n\t\t&lt;init-param&gt;\n\t\t\t&lt;param-name&gt;contextConfigLocation&lt;\/param-name&gt;\n\t\t\t&lt;param-value&gt;classpath:\/\/spring-config.xml&lt;\/param-value&gt;\n\t\t&lt;\/init-param&gt;\n\t\t&lt;load-on-startup&gt;1&lt;\/load-on-startup&gt;\n\t&lt;\/servlet&gt;\n\t\n\t &lt;servlet-mapping&gt;\n      &lt;servlet-name&gt;springFlowApplication&lt;\/servlet-name&gt;\n      &lt;url-pattern&gt;\/&lt;\/url-pattern&gt;\n   &lt;\/servlet-mapping&gt;\n&lt;\/web-app&gt;\n\n<\/pre>\n<p>Here&#8217;s the default view of our Flow which is backed by a Spring bean. The name of the input boxes are same as the property names in the backing PoJo. In case the developer wants to name them separately, he may use the Spring tag library and the <code>path<\/code> attribute.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>login.jsp<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted brush:java\">&lt;%@ page isELIgnored=\"false\"%&gt;\n&lt;html&gt;\n&lt;body&gt;\n\t&lt;h2&gt;Please Login&lt;\/h2&gt;\n\n\t&lt;form method=\"post\" action=\"${flowExecutionUrl}\"&gt;\n\n\t\t&lt;input type=\"hidden\" name=\"_eventId\" value=\"performLogin\"&gt; \n\t\t&lt;input type=\"hidden\" name=\"_flowExecutionKey\" value=\"${flowExecutionKey}\" \/&gt;\n\n\t\t&lt;input type=\"text\" name=\"userName\" maxlength=\"40\"&gt;&lt;br&gt; \n\t\t&lt;input type=\"password\" name=\"password\" maxlength=\"40\"&gt;\n\t\t&lt;input type=\"submit\" value=\"Login\" \/&gt;\n\n\t&lt;\/form&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/pre>\n<p>This is the view rendered upon successful authentication.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>success.jsp<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted brush:java\">&lt;%@ page language=\"java\" contentType=\"text\/html; charset=ISO-8859-1\"\n    pageEncoding=\"ISO-8859-1\"%&gt;\n    &lt;%@ page isELIgnored =\"false\" %&gt;\n&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/loose.dtd\"&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=ISO-8859-1\"&gt;\n&lt;title&gt;Login Successful&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\nWelcome ${loginBean.userName}!!\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/pre>\n<p>When entering the wrong credentials, the user is notified via this view:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>failure.jsp<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted brush:java\">&lt;%@ page language=\"java\" contentType=\"text\/html; charset=ISO-8859-1\"\n    pageEncoding=\"ISO-8859-1\"%&gt;\n    &lt;%@ page isELIgnored =\"false\" %&gt;\n&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/loose.dtd\"&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=ISO-8859-1\"&gt;\n&lt;title&gt;Login Successful&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\nInvalid username or password. Please try again!\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/pre>\n<p>Now, let&#8217;s deploy and run the code. I have used Apache Tomcat 7 for this example. Here&#8217;s the output for the first page:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Login-page.jpg\"><img decoding=\"async\" width=\"777\" height=\"254\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Login-page.jpg\" alt=\"spring web flow - Login page\" class=\"wp-image-36924\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Login-page.jpg 777w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Login-page-300x98.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Login-page-768x251.jpg 768w\" sizes=\"(max-width: 777px) 100vw, 777px\" \/><\/a><figcaption>Fig 1 : Login page<\/figcaption><\/figure>\n<\/div>\n<p>Upon successful authentication :<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/successful-login-flow.jpg\"><img decoding=\"async\" width=\"778\" height=\"167\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/successful-login-flow.jpg\" alt=\"spring web flow - Successful login flow\" class=\"wp-image-36925\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/successful-login-flow.jpg 778w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/successful-login-flow-300x64.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/successful-login-flow-768x165.jpg 768w\" sizes=\"(max-width: 778px) 100vw, 778px\" \/><\/a><figcaption>Fig 2 : Successful login flow<\/figcaption><\/figure>\n<\/div>\n<p>Upon entering Invalid Credentials:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Failed-Login-Flow.jpg\"><img decoding=\"async\" width=\"777\" height=\"172\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Failed-Login-Flow.jpg\" alt=\"spring web flow - Failed Login Flow\" class=\"wp-image-36926\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Failed-Login-Flow.jpg 777w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Failed-Login-Flow-300x66.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Failed-Login-Flow-768x170.jpg 768w\" sizes=\"(max-width: 777px) 100vw, 777px\" \/><\/a><figcaption>Fig 3 : Failed Login Flow<\/figcaption><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\" id=\"h-4-download-the-source-code\">4. Download The Source Code<\/h2>\n<p>In this example, we demonstrated how our view flows could be defined clearly and hence, managed easily and minutely using Spring Web-Flow.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the source code of this example here: <a class=\"ext-link\" title=\"\" href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/SpringWebFlowExample.zip\" rel=\"external nofollow\"><strong>Spring Web Flow Tutorial<\/strong><\/a><\/div>\n<p><strong>Last updated on Jun. 29th, 2021<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this example, we will demonstrate what is Spring Web-Flow, what are its benefits, and how to configure it in a web application. In the previous article, we have demonstrated how Spring MVC can be configured. 1. Introduction Spring MVC is a powerful framework that allows the user to configure and manage the flow of &hellip;<\/p>\n","protected":false},"author":30,"featured_media":1248,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1459],"tags":[],"class_list":["post-36272","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-flow"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring Web Flow Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this example, we will demonstrate what is Spring Web-Flow, what are its benefits, and how to configure it in a web application. In the previous\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Web Flow Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this example, we will demonstrate what is Spring Web-Flow, what are its benefits, and how to configure it in a web application. In the previous\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-05T12:00:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-29T10:07:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Chandan Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chandan Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/\"},\"author\":{\"name\":\"Chandan Singh\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/86537f90d4f34206febe90a0fbd6cd33\"},\"headline\":\"Spring Web Flow Tutorial\",\"datePublished\":\"2016-05-05T12:00:01+00:00\",\"dateModified\":\"2021-06-29T10:07:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/\"},\"wordCount\":940,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"articleSection\":[\"Web Flow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/\",\"name\":\"Spring Web Flow Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"datePublished\":\"2016-05-05T12:00:01+00:00\",\"dateModified\":\"2021-06-29T10:07:19+00:00\",\"description\":\"In this example, we will demonstrate what is Spring Web-Flow, what are its benefits, and how to configure it in a web application. In the previous\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"spring\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Web Flow\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/web-flow\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Spring Web Flow Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/86537f90d4f34206febe90a0fbd6cd33\",\"name\":\"Chandan Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/Chandan-Singh-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/Chandan-Singh-96x96.jpg\",\"caption\":\"Chandan Singh\"},\"description\":\"Chandan holds a degree in Computer Engineering and is a passionate software programmer. He has good experience in Java\/J2EE Web-Application development for Banking and E-Commerce Domains.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/chandan-singh\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Web Flow Tutorial - Java Code Geeks","description":"In this example, we will demonstrate what is Spring Web-Flow, what are its benefits, and how to configure it in a web application. In the previous","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Spring Web Flow Tutorial - Java Code Geeks","og_description":"In this example, we will demonstrate what is Spring Web-Flow, what are its benefits, and how to configure it in a web application. In the previous","og_url":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2016-05-05T12:00:01+00:00","article_modified_time":"2021-06-29T10:07:19+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Chandan Singh","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Chandan Singh","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/"},"author":{"name":"Chandan Singh","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/86537f90d4f34206febe90a0fbd6cd33"},"headline":"Spring Web Flow Tutorial","datePublished":"2016-05-05T12:00:01+00:00","dateModified":"2021-06-29T10:07:19+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/"},"wordCount":940,"commentCount":6,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","articleSection":["Web Flow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/","url":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/","name":"Spring Web Flow Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","datePublished":"2016-05-05T12:00:01+00:00","dateModified":"2021-06-29T10:07:19+00:00","description":"In this example, we will demonstrate what is Spring Web-Flow, what are its benefits, and how to configure it in a web application. In the previous","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/spring-web-flow-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/"},{"@type":"ListItem","position":4,"name":"spring","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/"},{"@type":"ListItem","position":5,"name":"Web Flow","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/web-flow\/"},{"@type":"ListItem","position":6,"name":"Spring Web Flow Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/86537f90d4f34206febe90a0fbd6cd33","name":"Chandan Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/Chandan-Singh-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/Chandan-Singh-96x96.jpg","caption":"Chandan Singh"},"description":"Chandan holds a degree in Computer Engineering and is a passionate software programmer. He has good experience in Java\/J2EE Web-Application development for Banking and E-Commerce Domains.","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/chandan-singh\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/36272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=36272"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/36272\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1248"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=36272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=36272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=36272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}