Spring Web Flow configuration file

Source: Internet
Author: User

<?xml version= "1.0" encoding= "UTF-8"?>
<beans xmlns= "Http://www.springframework.org/schema/beans"
xmlns:context= "Http://www.springframework.org/schema/context"
xmlns:p= "http://www.springframework.org/schema/p"
Xmlns:mvc= "Http://www.springframework.org/schema/mvc"
xmlns:tx= "Http://www.springframework.org/schema/tx"
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-3.0.xsd
Http://www.springframework.org/schema/context
Http://www.springframework.org/schema/context/spring-context.xsd
Http://www.springframework.org/schema/tx
Http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
Http://www.springframework.org/schema/mvc
Http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd ">

<bean id= "Viewresolver" class= "Org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name= "prefix" value= "/"/>
<property name= "suffix" value= ". jsp"/>
</bean>
<bean class= "org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<bean class= "Org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >
<property name= "Mappings" >
<props>
<prop key= "/index" >index1</prop>
<prop key= "/shopping" >flowController</prop>
</props>
</property>
</bean>
<bean id= "index1" class= "Org.springframework.web.servlet.mvc.ParameterizableViewController" >
<property name= "ViewName" value= "index" ></property>
</bean>

<bean id= "Flowcontroller" class= "Org.springframework.webflow.mvc.servlet.FlowController" >
<property name= "Flowexecutor" ref= "Flowexecutor"/>
</bean>
<!--Flowcontroller can understand the entry of flow, which is the point of integration between spring MVC and Spring web flow, and handing over the request to the word controller means entering flow. Specifically into which flow is determined by flowexecutor, the way of judging is based on the URL of the request, then in this case will go to flow with ID shopping -

</beans>





<?xml version= "1.0" encoding= "UTF-8"?>
<beans xmlns= "Http://www.springframework.org/schema/beans"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" 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-2.5.xsd
Http://www.springframework.org/schema/webflow-config
Http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd ">
<webflow:flow-executor id= "Flowexecutor" flow-registry= "Flowregistry"/>
<!--all flow definition files Its location is configured here, Flow-builder-services is used to configure flow features--
<webflow:flow-registry id= "Flowregistry" flow-builder-services= "Flowbuilderservices" >
<webflow:flow-location path= "/web-inf/flows/shopping.xml" id= "shopping"/>
<webflow:flow-location path= "/web-inf/flows/addtocart.xml" id= "AddToCart"/>
</webflow:flow-registry>
<!--views in Web Flow are presented through the MVC Framework's view technology-
<webflow:flow-builder-services id= "flowbuilderservices" view-factory-creator= "MvcViewFactoryCreator"/>
<!--The view resolver of the MVC framework, which is used to find resources through the view name-
<bean id= "Mvcviewfactorycreator" class= "Org.springframework.webflow.mvc.builder.MvcViewFactoryCreator" >
<property name= "Viewresolvers" ref= "Viewresolver"/>
</bean>
</beans>






<?xml version= "1.0" encoding= "UTF-8"?>

<flow xmlns= "Http://www.springframework.org/schema/webflow"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xsi:schemalocation= "Http://www.springframework.org/schema/webflow
Http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd ">
<!--view-state the JSP page in the JSP folder for the view, on is the trigger event, to the state ID--
<!--<var name= "Mycart" class= "bean. Cart "/> Represents a variable named Mycart that has a value of bean. Cart Class object
This approach can be replaced with spring annotations: @Component ("Mycart")
-
<on-start> <!--means to do so before entering this flow
<set name= "Conversationscope.cart" value= "Mycart" ></set> <!--means putting Mycart into a cart in the conversation range-- >
</on-start>
<view-state id= "Viewcart" view= "/jsp/viewcart" > <!--we can see that this is the first state of this flow, so when you get to this flow--
<on-render> <!--Before this view is rendered, execute the business logic--<!--first executes the state, which goes to the Viewcart page--
<evaluate expression= "productservice.getproducts ()" result= "Viewscope.products"/>
<!--expression expression represents business logic that puts the return value of the method into products within the view range--
</on-render>
<transition on= "Submit" to= "ViewOrder" ><!--when in this state, if the submit is triggered, it will turn to viewOrder state--
</transition>
<transition on= "AddToCart" to= "Addproducttocart"/>
</view-state>
<view-state id= "ViewOrder" view= "/jsp/vieworder" >
<transition on= "Confirm" to= "orderconfirmed" >
</transition>
</view-state>
<view-state id= "orderconfirmed" view= "/jsp/viewconfirmed" >
<transition on= "Returntoindex" to= "Returntoindex" >
</transition>
</view-state>
<end-state id= "Returntoindex" view= "index" >
</end-state><!--the end state of the flow, no more turning to other states--

<subflow-state id= "Addproducttocart" subflow= "AddToCart" > <!--sub-stream, Subflow indicates the ID of the child flow--
<transition on= "productadded" to= "Viewcart"/>
</subflow-state>

</flow>





<?xml version= "1.0" encoding= "UTF-8"?>
<flow xmlns= "Http://www.springframework.org/schema/webflow"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xsi:schemalocation= "Http://www.springframework.org/schema/webflow
Http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd ">
<on-start>
<set name= "Requestscope.productid" value= "Requestparameters.productid"/>
</on-start>
<action-state id= "AddToCart" >
<evaluate expression= "Cart.additem (productservice.getproduct (productId))"/>
<transition to= "productadded"/>
</action-state> <!--This state is used to process business logic--
<end-state id= "productadded"/>
</flow>


Spring Web Flow configuration file

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.