throwExceptionIfNoHandlerFound
was introduced in DispatcherServlet
in Spring 4.0.
I have tried to figure out how to set this property in the autoconfigured DispatcherServlet
provided by Spring Boot, but no luck.
Some digging suggests the snippet below should work, but it doesn't.
@Bean
public ServletContextInitializer servletContextInitializer() {
return new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("throwExceptionIfNoHandlerFound", "true");
}
};
}