Saturday, May 16, 2015

How to add mappings from URLs to view names by Java Config in Spring

In Spring, to add mappings from URLs to view names by Java Config,

do the following:

@Configuration
public class WebConfig extends WebMvcConfigurerAdapter{

  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/").setViewName("index");
  }

}

Reference:
http://stackoverflow.com/questions/17049032/spring-bean-configuration-equivalent-to-mvcview-controller-path

No comments:

Post a Comment