Answer the question
In order to leave comments, you need to log in
What is the correct way to forward all requests in Spring?
There is a SpringApplication created by the designer, without the WEB_INF folder and settings in xml.
Can you please tell me how to correctly redirect all requests to static/index.html, except for those whose processing is registered in the controller?
Answer the question
In order to leave comments, you need to log in
like this (not sure about prioritization over other ViewControllers):
import org.springframework.core.Ordered;
@Configuration
public class CustomSpringConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addRedirectViewController("/*", "/static/index.html");
registry.setOrder(Ordered.LOWEST_PRECEDENCE);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question