throwExceptionIfNoHandlerFound
DispatcherServlet
在 Spring 4.0 中引入。
我试图弄清楚如何在DispatcherServlet
Spring Boot 提供的自动配置中设置这个属性,但没有运气。
一些挖掘表明下面的代码段应该有效,但事实并非如此。
@Bean
public ServletContextInitializer servletContextInitializer() {
return new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("throwExceptionIfNoHandlerFound", "true");
}
};
}
Run Code Online (Sandbox Code Playgroud) spring-boot ×1