Mar
27
2014

spring web flow

In spring MVC the flow is shown below –

 

 

spring web flow

 

When the user click submit any form or click on hyper link request first goes to web.xml.

Code of a web.xml is like below

Step 1When user submit any form or click on any hyper link or make request by any other meaning then the request first goes to web.xml

Step 2Meaning of <url-pattern>*.html</url-pattern> in above code is that if any .html request that will come then it will be transfer to dispatcher-servlet.xml.

In <url-pattern>*.html</url-pattern> the url-pattern *.html is can be changed to any other extension like .htm or any other .In that case when the request that will come with .htm or any other extension that is mention in between *.tag extension then it will be transfer to dispatcher-servlet.xml.

Step 3 The dispatcher-servlet then ask the Handller-Mapping to finds the controller class where mapping for the request exist.

Step4 Request is then transfer to the controller class where mapping for the request exist.The method for this mapping will execute.

Step 5 The return type of the method associated with mapping cold be String or ModelAndView.When some date is sent along with response then the return ModelAndView is required because it allow to pass three parameter to pass in its constructor . Among the three parameter first is the response page ,second is of string type that is the name and the final is a parameter is data object that is being sent with the response.The other constructor is just similar when only the response page is return. Another return type is String and is used when only a response page is sent back without any data object.

Step 6 Either string or ModelAndView is return to dispatcher-servlet.

Step 7 Dispatcher-servlet will pass the returning response to InternalViewResolver.

Step 8 InternalViewResolver then find the exact page with the help of configuration information provided in

dispatcher-servlet.InternalViewResolver add the suffix .jsp to the name that has come from controller class to dispatcher-servle and return the response back to the user .

The complete example is given in the next tutorial .

About the Author: devender kumar

java/j2EE developer

Comments are closed.