To implement the shopping cart process for the sample application, follow these steps:
Import a related class library under the/web-inf/lib directory
Add a configuration with Spring Web flow integration in Webmvc-config.xml
Add a configuration file for Spring Web flow webflow-config.xml
Add a flow definition file Shopping.xml
Add three JSP pages
Modify Index.jsp
Import a related class library under the/web-inf/lib directory
Import the following jar packages into the/web-inf/lib directory:
Org.springframework.webflow-2.0.2.release.jar
Org.springframework.js-2.0.2.release.jar
Org.springframework.binding-2.0.2.release.jar
Jboss-el.jar
Adding a configuration to the Webmvc-config.xml
The Spring Web MVC-related configuration was previously analyzed, and the complete configuration is shown in Listing 13:
List Webmvc-config.xml<?xml version= "1.0" encoding= "UTF-8"?>
<beans
Xmlns= "Http://www.springframework.org/schema/beans"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xsi:schemalocation= "Http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans.xsd ">
<bean
Id= "Viewresolver"
class= "Org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name= "Viewclass" value= "Org.springframework.web.servlet.view.JstlView" >
</property>
<property name= "prefix" value= "/web-inf/jsp/" >
</property>
<property name= "suffix" value= ". jsp" >
</property>
</bean>
<bean
Id= "Viewmappings"
class= "Org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >
<!--/shopping.do requests are handled by Flowcontroller-->
<property name= "Mappings" >
<value>/shopping.do=flowcontroller </value>
</property>
<property name= "DefaultHandler" >
<!--Urlfilenameviewcontroller will map requests such as "/index" to the view named "Index"-->
<bean class= "Org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
</property>
</bean>
<bean
Id= "Flowcontroller"
class= "Org.springframework.webflow.mvc.servlet.FlowController" >
<property name= "Flowexecutor" ref= "Flowexecutor"/>
</bean>
</beans>