|
@@ -1,5 +1,6 @@
|
|
package org.hsweb.web.controller;
|
|
package org.hsweb.web.controller;
|
|
|
|
|
|
|
|
+import org.hsweb.web.core.logger.annotation.AccessLogger;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
|
|
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
|
|
import org.springframework.boot.autoconfigure.web.ErrorController;
|
|
import org.springframework.boot.autoconfigure.web.ErrorController;
|
|
@@ -18,12 +19,14 @@ import java.util.Map;
|
|
|
|
|
|
@Controller
|
|
@Controller
|
|
@RequestMapping("/error")
|
|
@RequestMapping("/error")
|
|
|
|
+@AccessLogger("错误请求")
|
|
public class DefaultErrorController implements ErrorController {
|
|
public class DefaultErrorController implements ErrorController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ErrorAttributes errorAttributes;
|
|
private ErrorAttributes errorAttributes;
|
|
|
|
|
|
@RequestMapping
|
|
@RequestMapping
|
|
|
|
+ @AccessLogger("html")
|
|
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) {
|
|
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) {
|
|
RequestAttributes requestAttributes = new ServletRequestAttributes(request);
|
|
RequestAttributes requestAttributes = new ServletRequestAttributes(request);
|
|
Map<String, Object> model = errorAttributes.getErrorAttributes(requestAttributes, true);
|
|
Map<String, Object> model = errorAttributes.getErrorAttributes(requestAttributes, true);
|
|
@@ -34,6 +37,7 @@ public class DefaultErrorController implements ErrorController {
|
|
|
|
|
|
@RequestMapping(produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE})
|
|
@RequestMapping(produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE})
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
|
+ @AccessLogger("json")
|
|
public Object error(HttpServletRequest request, HttpServletResponse response) {
|
|
public Object error(HttpServletRequest request, HttpServletResponse response) {
|
|
RequestAttributes requestAttributes = new ServletRequestAttributes(request);
|
|
RequestAttributes requestAttributes = new ServletRequestAttributes(request);
|
|
Map<String, Object> model = errorAttributes.getErrorAttributes(requestAttributes, true);
|
|
Map<String, Object> model = errorAttributes.getErrorAttributes(requestAttributes, true);
|