Chapter 7. Advanced Spring MVC

 

This chapter covers

  • Alternate Spring MVC configuration options
  • Handling file uploads
  • Handling exceptions in controllers
  • Working with flash attributes

But wait! There’s more!

You’ve probably heard those words before if you’ve ever seen one of those “as seen on TV” ads for some gizmo or gadget. Just about the time the ad has completely described the product and made initial claims about what it can do, you hear, “But wait! There’s more!” and the ad continues to tell you just how much more amazing the product can be.

In many ways, Spring MVC (and, indeed, every part of Spring) has that feel of “There’s more!” Just about the time you think you’ve got your head around what Spring MVC can do, you find out there’s even more that you can do with it.

In chapter 5, we looked at essential Spring MVC and how to write controllers to handle various kinds of requests. Then you built on that in chapter 6 to create the JSP and Thymeleaf views that present model data to the user. You might think you know everything about Spring MVC. But wait! There’s more!

In this chapter, we’ll continue with the Spring MVC topic by covering a handful of features that exceed the basics covered in chapters 5 and 6. We’ll look at how to write controllers that accept file uploads, how to handle exceptions thrown from controllers, and how to pass data around in the model such that it survives a redirect.

7.1. Alternate Spring MVC configuration

7.2. Processing multipart form data

7.3. Handling exceptions

7.4. Advising controllers

7.5. Carrying data across redirect requests

7.6. Summary