Spring 报错页面

public class GlobalExceptionHandler implements ErrorViewResolver {
    @Override
    public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
        ModelAndView mav = new ModelAndView();
        mav.addObject("url", request.getRequestURL());
        mav.addAllObjects(model);
        mav.setViewName("error");
        return mav;
    }
}
@RequestMapping(value = "/error/{code}")
    public String error(@PathVariable int code, Model model) {
        String pager = "/content/error-pager";
        switch (code) {
            case 404:
                model.addAttribute("code", 404);
                pager = "/content/error-pager";
                break;
            case 500:
                model.addAttribute("code", 500);
                pager = "/content/error-pager";
                break;
        }
        return pager;
    }

你可能感兴趣的:(Spring,零碎)