Why:
Why do we need fast definition Viewcontroller?
In the project development process, often involves the page jump problem, and this page jump does not have any business logic process, just simple routing process (click a button to jump to a page).
The general wording is as follows:
@RequestMapping ("/toview") public String view () { return "View";}
If there are many similar non-business logic jump processes in your project, there will be a lot of similar code.
How:
How can you simply write this code?
Spring MVC provides a way to manage similar code in a unified manner, reducing the writing of similar code (depending on the project requirements, or code specification, not necessarily to manage page jumps uniformly, sometimes putting code for the same business logic in a class).
Overloading in WebMvcConfigurerAdapter
an inherited DemoMVCConfig
classaddViewControllers
@Override publicvoid addviewcontrollers (Viewcontrollerregistry Registry) { Registry.addviewcontroller ("/toview"). Setviewname ("/view"); // add more }
The above code is equivalent to the first notation.
Spring MVC Quick Definition Viewcontroller