admin 管理员组

文章数量: 887032


2024年1月5日发(作者:网页设计培训有哪些)

/** * 定义404的JSON数据 * @param request * @return */ @RequestMapping(value = "404") @ResponseBody public ResponseEntity> error404(HttpServletRequest request) { Map body = getErrorAttributes(request, isIncludeStackTrace(request, _HTML)); HttpStatus status = getStatus(request); return new ResponseEntity>(body, status); }

/** * 定义500的ModelAndView * @param request * @param response * @return */ @RequestMapping(produces = "text/html",value = "500") public ModelAndView errorHtml500(HttpServletRequest request, HttpServletResponse response) { tus(getStatus(request).value()); Map model = getErrorAttributes(request, isIncludeStackTrace(request, _HTML)); return new ModelAndView("error/500", model); }

/** * 定义500的错误JSON信息 * @param request * @return */ @RequestMapping(value = "500") @ResponseBody public ResponseEntity> error500(HttpServletRequest request) { Map body = getErrorAttributes(request, isIncludeStackTrace(request, _HTML)); HttpStatus status = getStatus(request); return new ResponseEntity>(body, status); }

/** * Determine if the stacktrace attribute should be included. * @param request the source request * @param produces the media type produced (or {@code }) * @return if the stacktrace attribute should be included */ protected boolean isIncludeStackTrace(HttpServletRequest request, MediaType produces) { eStacktrace include = or().getIncludeStacktrace(); if (include == ) { return true; } if (include == _TRACE_PARAM) { return getTraceParameter(request); } return false; }

/** * 获取错误的信息 * @param request * @param includeStackTrace * @return */ private Map getErrorAttributes(HttpServletRequest request, boolean includeStackTrace) { RequestAttributes requestAttributes = new ServletRequestAttributes(request); return orAttributes(requestAttributes, includeStackTrace); }

/** * 是否包含trace * @param request * @return */ private boolean getTraceParameter(HttpServletRequest request) { String parameter = ameter("trace"); if (parameter == null) { return false; }


本文标签: 错误 信息 设计 是否 网页