@Controller
public class CentralizedExceptionController extends DefaultHandlerExceptionResolver {
@Override
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex, HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
System.out.println("working?!");
return new ModelAndView();
}
我在我的代码中有这个,但是在404从未调用过的情况下。 (我没有在我的web.xml中定义的错误页面,我不想)handleNoSuchRequestHandling方法覆盖不起作用
这不起作用。它只在将此方法放在创建404的相同类中时才起作用。 – 2012-03-09 08:17:37