Home Spring Spring3.2 View Controllers Configuration



View Controllers Configuration
Posted on: March 21, 2013 at 12:00 AM
In this section, you will learn about configuring ParameterizableViewController through MVC Java config and XML Namespace.

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



Related Tags for View Controllers Configuration:


More Tutorials from this section

Ask Questions?    Discuss: View Controllers Configuration  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.