Java Code Examples for org.springframework.web.servlet.NoHandlerFoundException#getMessage()

The following examples show how to use org.springframework.web.servlet.NoHandlerFoundException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlobalExceptionHandler.java    From Spring-Boot-Book with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: GlobalExceptionHandler.java    From Spring-Boot-Book with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: GlobalExceptionHandler.java    From SENS with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: ExceptionAdvice.java    From ProjectStudy with MIT License 4 votes vote down vote up
/**
 * 捕捉404异常
 * @return
 */
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseBean handle(NoHandlerFoundException e) {
    return new ResponseBean(HttpStatus.NOT_FOUND.value(), e.getMessage(), null);
}
 
Example 5
Source File: ExceptionAdvice.java    From ProjectStudy with MIT License 4 votes vote down vote up
/**
 * 捕捉404异常
 * @return
 */
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseBean handle(NoHandlerFoundException e) {
    return new ResponseBean(HttpStatus.NOT_FOUND.value(), e.getMessage(), null);
}
 
Example 6
Source File: ExceptionAdvice.java    From ProjectStudy with MIT License 4 votes vote down vote up
/**
 * 捕捉404异常
 * @return
 */
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseBean handle(NoHandlerFoundException e) {
    return new ResponseBean(HttpStatus.NOT_FOUND.value(), e.getMessage(), null);
}
 
Example 7
Source File: ExceptionAdvice.java    From ShiroJwt with MIT License 4 votes vote down vote up
/**
 * 捕捉404异常
 * @return
 */
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseBean handle(NoHandlerFoundException e) {
    return new ResponseBean(HttpStatus.NOT_FOUND.value(), e.getMessage(), null);
}