Home Spring Spring3.2 View Controllers Configuration
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

View Controllers Configuration

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



Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 21, 2013

Ask Questions?    Discuss: View Controllers Configuration  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com