0

I am developing a spring application (annotation based configurations) in which index.jsp is my default welcome page. but now I don't want to display index.jsp as my welcome page and want to change it to home.jsp. how can I achieve this?

I tried below method from WebMvcConfigurerAdapter class

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

it is not working.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Sudharma
  • 11
  • 1

1 Answers1

1

You need to forward the default mapping. Hope this may help you!

@Configuration
public class YourViewClass extends WebMvcConfigurerAdapter
{
    @Override
    public void addViewControllers( ViewControllerRegistry registry ) 
    {
        registry.addViewController( "/" ).setViewName( "forward:/yourhomepage.html" );
        registry.setOrder( Ordered.HIGHEST_PRECEDENCE );
        super.addViewControllers( registry );
    }
}
CyamiAnbu
  • 41
  • 4