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...

  1. In the cloudstreetmarket-webapp module and in the package edu.zipcloud.cloudstreetmarket.portal.controllers, the following DefaultController has been created:
    @Controller public class DefaultController { @RequestMapping(value="/*", method={RequestMethod.GET,RequestMethod.HEAD}) ...

Get Spring MVC Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.