Search This Blog

Sunday, July 8, 2012

Spring MVC 3.1 Presentation and Tutorial

A few months ago, I had a chance to present on Spring MVC. It was a simple 45 minute presentation but I had a blast doing it.  A friend of mine had asked whether I could share the same and this BLOG post is exactly that.

My audience for the presentation had no experience with the framework and therefore my presentation was geared toward introducing the same to them. A Spring MVC presentation without supporting code is like having a cake without the icing. So included herewith is also the code I developed for the same.

The model object of interest for the demo code is an Application in some company's domain. It could be any application such as a web app, web service or whatever. The Application has a single property, its name. The final example demonstrates connectivity between applications using arbor.js to display the relationship.

The examples provided are in the form of a multi-module maven project and are meant to gradually progress a reader into Spring MVC.

1. springMvcBasic

This is the basic project and provides the simplest example of a Controller that renders a list of applications.

 2. springMvcFormValidation

The springMvcFormValidation module demonstrates the use of JSR 303 validations of Forms and form submission.

3. springMvcRequestResponses

This project demonstrates the use of the REST support of Spring MVC by sending and receiving XML and JSON.

4. springMvcDecorated

The springMvcDecorated module is conglomeration of the above examples and also demonstrates the following:

a. Internationalization
b. Spring Theme support using Twitter Bootstrap for the styling.
c. arbor.js for demonstrating application interaction
d. displayTag and dataTables.js for table support
e. sitemesh for decorating pages

Enter into each project and execute a mvn jetty:run to start the application. You can access each application at the corresponding ports.

The presentation is attached herewith.  The code samples can be downloaded from here.

Follow the presentation along with the provided examples to see it in action. I am grateful to the multitude of community presentations and blogs that helped me with my presentation.