查找最简单的方法是使用以下命令:
@ExceptionHandler(Throwable.class) public String handleAnyException(Throwable ex, HttpServletRequest request) { return ClassUtils.getShortName(ex.getClass()); }如果URL在DispatcherServlet的范围内,则任何由于错误输入或其他原因引起的404都将被此方法捕获,但是如果键入的URL超出DispatcherServlet的URL映射,则你必须使用以下任一方法:
<error-page> <exception-type>404</exception-type> <location>/404error.html</location></error-page>
要么
为你的DispatcherServlet映射URL提供“ /”映射,以便处理特定服务器实例的所有映射。



