In this section, you will learn about configuring ParameterizableViewController through MVC Java config and XML Namespace.
The configuration describe in this section is a shortcut for defining a ParameterizableViewController which instantly redirect a request to a view without visiting controller.
It can be utilize in a situation when controller has no Java logic code to execute before the view renders the response.
Given below MVC Java config to forward to a view "home", when gets a request for "/" :
@Configuration
@EnableWebMvc
public class MyWebAppConfig extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index");
}
}
You can do the same in MVC XML Namespace using element <mvc:view-controller> as :
<mvc:view-controller path="/" view-name="index"/>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: View Controllers Configuration
Post your Comment