I start my web application with spring boot. It use a simple main class to start an embedded tomcat server:
@Configuration
@EnableAutoConfiguration
@Componen
You can forward all not found resources to your main page by providing custom ErrorViewResolver. All you need to do is to add this to your @Configuration class:
@Bean
ErrorViewResolver supportPathBasedLocationStrategyWithoutHashes() {
return new ErrorViewResolver() {
@Override
public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map model) {
return status == HttpStatus.NOT_FOUND
? new ModelAndView("index.html", Collections.emptyMap(), HttpStatus.OK)
: null;
}
};
}