Reputation: 807
I've lost the automatic forward to index.html enabled by spring-boot-starter-web
since I changed the server.servlet.path=/spring
to have acuators endpoints under /spring.
I have a pure REST API app, I'm using Jersey for my endpoints @ApplicationPath("/user)
, but I want to use the default / context to redirect to index.html for an API documentation.
I've tried the solution indicated in Java Spring Boot: How to map my app root (“/”) to index.html? but to no avail:
@Configuration
public class WebMvcConfiguration {
@Bean
public WebMvcConfigurerAdapter forwardToIndex() {
return new WebMvcConfigurerAdapter() {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
// redirect requests to / to index.html
registry.addViewController("/").setViewName("redirect:/index.html");
}
};
}
Is it possible to enable it ?
Upvotes: 3
Views: 2571
Reputation: 33121
Well, you're not serving /
at all now. Since your change, Spring Boot only handles whatever comes at /spring
.
That code of yours is actually asking /spring/
to redirect to /spring/index.html
.
Upvotes: 2