View Controllers Configuration

In this section, you will learn about configuring ParameterizableViewController through MVC Java config and XML Namespace.

View Controllers Configuration

--Ads--

View Controllers Configuration

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"/>