Chapter 8. Annotation-driven development with Spring
This chapter covers
- Spring Portlet MVC annotations
- Dependency injection using JSR 330 and JSR 250
- Validation using Spring Validation API and JSR 303
- Using Spring’s form tag library
- Localization and file upload support
- Unit testing with Spring’s TestContext framework
In the previous chapter, you created Spring controllers and provided a HandlerMapping bean definition in the web application context XML file to map portlet requests to appropriate controllers. But wouldn’t it be easier if you could specify which portlet request is handled by a controller in the controller class itself? In this chapter, we’ll expand on the core concepts covered in the previous chapter and see how Spring’s annotation support helps you reduce the amount of configuration information in the application context XML files and simplify application development.
The annotations covered in this chapter span multiple aspects of portlet development using Spring, from writing request handlers, to dependency injection, to validation and testing. This chapter demonstrates these aspects in the development of the Book Catalog portlet, to show how Spring simplifies portlet development using annotations.