Basic Web MVC Example - In Pictures
It seems that some of you would like a graphical depiction of what’s going on in the Basic Spring Web MVC Example. Here it is:

Here’s a summary, though I urge you to read the original blog entry and view the source for more details:
- A request comes in from the web cloud and your web container, Tomcat say, will examine its configuration
web.xmlto determine what to do with it. - Here we’ve assumed that
web.xmlwas configured to map to a dispatcher servlet (in the example, it mapped/send/*requests. There can be any number of dispatcher servlets configured. - Once a dispatcher servlet receives a request, it needs to know which controller to send it to. It does this with a URL mapper. The URL mapper will typically send a request to one of many configured controllers. In our example, we mapped everything (
/*) that arrives at the dispatch servlet to a singledispatchController. - Incoming requests at a controller actually need to invoke a method on the controller. We’re using a
MultiActionControllerin our example, and this uses aMethodNameResolverto determine which method to invoke. The default resolver simply takes what’s to the right of the last “/” in the incoming URL. - Once the action has executed, the result has to be sent to a view. Which view, is determined by a
ViewResolver. In our example, we used aInternalResourceViewResolverwith a configuration such that given a view name of “foo“, will look for a JSP file “foo.jsp“. - The view is rendered.
As you can tell, everything is very flexible. We can configure which dispatcher servlets are invoked when, we can configure which controller is invoked, we can configure which methods on the controller are invoked, and we can configure how the view is selected. What’s more, we can use all of the defaults to get a pretty flexible application up and running in no time.
Print This Post
on May 8th, 2006 at 6:52 am
[…] MemeStorm » Basic Web MVC Example – In Pictures […]
on October 12th, 2006 at 1:45 am
[…] Let’s look at how to create a simple session-scoped bean that can be retrieved from the context. If you are using a DispatcherServlet (which you will be if you are using Spring’s MVC) then all you need to do is tag the bean as session-scoped in your application context configuration file. For example: […]