下面列出了org.springframework.web.servlet.NoHandlerFoundException#getMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 404 - Not Found
*/
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public String noHandlerFoundException(NoHandlerFoundException e, Model model) {
logger.error("Not Found", e);
String message = "【页面不存在】" + e.getMessage();
model.addAttribute("message", message);
model.addAttribute("code", 404);
System.out.println("404404错误");
return viewName;
}
/**
* 404 - Not Found
*/
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public String noHandlerFoundException(NoHandlerFoundException e, Model model) {
logger.error("Not Found", e);
String message = "【页面不存在】" + e.getMessage();
model.addAttribute("message", message);
model.addAttribute("code", 404);
System.out.println("404404错误");
return viewName;
}
/**
* 404 - Not Found
*/
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public String noHandlerFoundException(NoHandlerFoundException e, Model model) {
log.error("Not Found", e);
String message = "【页面不存在】" + e.getMessage();
model.addAttribute("message", message);
model.addAttribute("code", 404);
return viewName;
}
/**
* 捕捉404异常
* @return
*/
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseBean handle(NoHandlerFoundException e) {
return new ResponseBean(HttpStatus.NOT_FOUND.value(), e.getMessage(), null);
}
/**
* 捕捉404异常
* @return
*/
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseBean handle(NoHandlerFoundException e) {
return new ResponseBean(HttpStatus.NOT_FOUND.value(), e.getMessage(), null);
}
/**
* 捕捉404异常
* @return
*/
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseBean handle(NoHandlerFoundException e) {
return new ResponseBean(HttpStatus.NOT_FOUND.value(), e.getMessage(), null);
}
/**
* 捕捉404异常
* @return
*/
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseBean handle(NoHandlerFoundException e) {
return new ResponseBean(HttpStatus.NOT_FOUND.value(), e.getMessage(), null);
}