Because the project needs to use the Wizard Page jump effect, this project is implemented with spring MVC. At first, we thought of using spring webflow, but webflow is too cumbersome, for our not very complex jump, we seem to have the feeling of "getting rid of your teeth". So we searched online to see if there were any similar solutions, the answer on the internet is generally to ask you to inherit the abstractwizardformcontoller class for implementation, but for spring mvc3.0.x this class will not be used, instead we recommend using annotations for implementation, so refer to the official documentation, the Wizard Page is implemented by annotation.
Below isCodeExample:
@ Controller @ requestmapping ("/wizard.htm") // The variable to be saved in the session @ sessionattributes ("Bean") public class testwizardcontroller {@ Resource (name = "beanservice ") private beanservice; @ requestmapping Public String Step1 (final modelmap) {modelmap. addattribute ("Bean", new bean (); Return "Step1" ;}@ requestmapping (Params = "_ step = 2 ") public String step2 (final @ modelattribute ("Bean") bean, final errors) {return "step2" ;}@ requestmapping (Params = "_ step = 3 ") public String Step3 (final @ modelattribute ("Bean") bean, final errors) {return "Step3" ;}@ requestmapping (Params = "_ finish ") public String processfinish (@ modelattribute ("Bean") bean, final errors, final modelmap, final sessionstatus status) {beanservice. add (bean); status. setcomplete (); Return "success" ;}@ requestmapping (Params = "_ cancel") Public String processcancel (final httpservletrequest request, final httpservletresponse response, final sessionstatus status) {status. setcomplete (); Return "cancel ";}}
The annotation @ sessionattributes is the most effective one. It defines a variable within the session range, which can be maintained during different page jumps.
When you access http:/www./example.com/wizard.htmfor the first time, go to step 1, and add the corresponding response to the table ticket action2. for example:
Step 1 page <form action = "http:/www./example.com/wizard.htm? _ Step = 2 ">
Step 2 page <form action = "http:/www./example.com/wizard.htm? _ Step = 3 ">
Step 3 page <form action = "http:/www./example.com/wizard.htm? _ Finish ">