Home > Software Development > Learning Spring MVC

Learning Spring MVC

February 16th, 2010 Leave a comment Go to comments

Today is my first day in a four day training – Rich Web Applications With Spring. It’s a pretty intensive day from 7AM to 3PM which covered the following:

  • Quick start with Spring Tool Suite  and reference application.
  • Spring MVC essentials, including architecture, controllers, conventions.
  • Using layouts and views, including composite views with Apache Tiles, and multiple rendering technologies like Excel, PDF in addition to the HTML.
  • Processing form pages, including data binding, validation, and form tags.

I used Java Servlet and JSP about 10 years ago while working on a NMS project. At that time, there was no good MVC framework for developing a large web application. You had to program against the Java Servlet APIs directly. Jason Hunter’s book Java Servlet Programming was my favorite book.

Time to learn how to "Google" and manage your VMware and clouds in a fast and secure


When the web applications get more complicated, you need extra flexibilities. Several frameworks like Struts were born. I bought a book on Struts later on and tried to understand how it worked. Struts was pretty complicated and I forgot what I learnt when I read to the end of the book. Overall the learning curve was pretty steep.

One of the difficulties came from over-using of XML configurations. Most things are configurable, which is good on one hand because you can, and bad on the other hand because you have to. To get a small task done, you have to write multiple XML configuration files. These XML files are not part of the source code and the linkage between them cannot be automated. Good exercises for brain!

Spring MVC is a late comer to the game, but has done a fairly good job. It uses annotations extensively. Even though you have to define similar information but making it right with the Java code makes the life way easier. It also follows the convention over configuration principle, therefore avoids some configurations whenever possible.

Building your web applications on frameworks like Spring MVC is great. It’s still a good choice using Java Servlet API directly if your web application is simple and small.

Some of you may still remember the contest in Steve Herrod’s keynote at VMworld 2009. Everyone attends or watches the keynote can submit her names via http://www.code2cloud.com to win the chance to see the Foreigner band in backstage at the celebration party.

When I designed and implemented the web application, I made several design choices to simplify it. For example, I didn’t use any MVC framework but Java Servlet API directly; I didn’t use database but save all the submission in the memory. To address the persistence issue, I designed a secret admin page from which I could list all the submissions to a HTML page which can be saved to any browser’s local file system any time. I could also pick the top 20 winners randomly, and reset submission list, all with one click.

The resulted code for the web application is very small, and the performance well exceeded the demand even with 1G memory VM hosted in Terremark vCloudEnterprise. We tested 10 times more capacity than we actually saw at the keynote.

  1. No comments yet.
  1. No trackbacks yet.