其他错误都会进入到这里,唯有404错误不进来?网上文档文章都说这样玩的,真奇怪。
404页面一直报这个错误,不进入我的自定义设置
**Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sun Jun 03 11:50:14 CST 2018
There was an unexpected error (type=Not Found, status=404).
No message available**
@ControllerAdvice
public class GlobalExceptionHandler {
private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
public static final String DEFAULT_ERROR_VIEW = "error/400";
@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorHandler(HttpServletRequest request, Exception e) {
logger.info("系统异常", e);
ModelAndView m = new ModelAndView();
m.addObject("exception", e);
m.addObject("url", request.getRequestURL());
m.setViewName(DEFAULT_ERROR_VIEW);
return m;
}
}
如果配置了,可以捕获404
出现错误时, 直接抛出异常
spring.mvc.throw-exception-if-no-handler-found=true
不要为我们工程中的资源文件建立映射
spring.resources.add-mappings=false
但是css js什么的都无法访问了。
检查一下路径和页面的位置