Configuring a fallback controller using ViewResolver
This recipe introduces some more advanced concepts and tools related to Controllers such as ViewResolvers
, URI Template Patterns, and Spring MVC's injection-as-argument. The recipe is quite simple but there is more to talk about.
Getting ready
We will keep working from the same codebase state as the previous recipe where we have pulled the v2.2.1 tag from the remote repository. It will only be about creating one Controller with its handler method.
How to do it...
- In the cloudstreetmarket-webapp module and in the package
edu.zipcloud.cloudstreetmarket.portal.controllers
, the followingDefaultController
has been created:@Controller public class DefaultController { @RequestMapping(value="/*", method={RequestMethod.GET,RequestMethod.HEAD}) ...
Get Spring MVC: Designing Real-World Web Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.