Chapter 7. Building web applications with Spring MVC
This chapter covers
As an enterprise Java developer, you’ve likely developed a web-based application or two. For many Java developers, web-based applications are their primary focus. If you do have this type of experience, you’re well aware of the challenges that come with these systems. Specifically, state management, workflow, and validation are all important features that need to be addressed. None of these is made any easier given the HTTP protocol’s stateless nature.
Spring’s web framework is designed to help you address these concerns. Based on the Model-View-Controller (MVC) pattern, Spring MVC helps you build web-based applications that are as flexible and as loosely coupled as the Spring Framework itself.
In this chapter we’ll explore the Spring MVC web framework. We’ll build controllers using the new Spring MVC annotations to handle web requests. As we do, we’ll strive to design our web layer in a RESTful way. Finally, we’ll wrap up by looking at how to use Spring’s JSP tags in views to send a response back to the user.
Before we go too deep with the specifics of Spring MVC controllers and handler mappings, let’s start with a high-level view of Spring MVC and set up the basic plumbing needed to make Spring MVC work.