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 followingDefaultControllerhas been created:@Controller public class DefaultController { @RequestMapping(value="/*", method={RequestMethod.GET,RequestMethod.HEAD}) public String fallback() { return "index"; } }Note
We will explain in detail how this method-handler serves as a fallback interceptor.
- Access the
http://localhost:8080/portal...