Hello World Web App using Spring Annotations Part 1

I’ve used the Spring Framework to build web applications for several years now.  I learned the old-fashioned way (if there is such a thing) of Spring MVC: SimpleFormController, AbstractController, Wizard controllers, and the rest of the MVC package.  Recently though, I had a chance to start a project from ground zero and upgraded to Spring 3.0.0.  It was also a good chance to learn about Spring Annotations and how they could make my life easier.

This is the first of what I hope to be a series of posts about building web applications using the Spring Framework.  If you are completely new to Spring, this post will hopefully help you get over the initial hump of learning Spring.  If you are familiar with Spring, but not with annotations for web applications, these posts will give you some examples.

Like most of the Java projects on this site, I’ll be using Eclipse, Maven, and the Sysdeo Tomcat plug-in.  You may want to read the Using Java Projects and Setting up Sysdeo postings for more information.

In this first post, we will build a version the classic Hello World as a web application using Spring.  Here are the requirements and goals:

  • Use a Spring MVC controller and a JSP page to show a simple message
  • Use Spring Annotations instead of the old MVC package
  • Minimum amount of XML configuration (in fact, it is 27 lines of XML in the end)
  • The message must come from the controller, not be hard-coded into the JSP
  • Package the web application into a WAR file (using Maven)

Continue reading Hello World Web App using Spring Annotations Part 1