Spring MVC 的 异常处理

@Controller
public class ExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseStatus(value = HttpStatus.NOT_FOUND)
    @ResponseBody
    public ErrorMessage handleResourceNotFoundException(Exception ex, HttpServletRequest request) {
        // do sth
    }
}

你可能感兴趣的:(spring,mvc,exception)