From f50e6ddcbff4eef2f2cbe1730daeac77b9123250 Mon Sep 17 00:00:00 2001 From: wangkang Date: Fri, 18 Aug 2017 17:48:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/exception/handle/ExceptionController.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionController.java b/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionController.java index 1a4870d..89602cc 100644 --- a/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionController.java +++ b/udf-starter-core/src/main/java/org/itkk/udf/core/exception/handle/ExceptionController.java @@ -1,7 +1,9 @@ package org.itkk.udf.core.exception.handle; +import org.itkk.udf.core.ApplicationConfig; import org.itkk.udf.core.RestResponse; import org.itkk.udf.core.exception.ErrorResult; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.web.AbstractErrorController; import org.springframework.boot.autoconfigure.web.ErrorAttributes; import org.springframework.boot.autoconfigure.web.ErrorProperties; @@ -34,6 +36,12 @@ public class ExceptionController extends AbstractErrorController { */ private final ErrorProperties errorProperties; + /** + * 描述 : 系统配置 + */ + @Autowired + private ApplicationConfig applicationConfig; + /** * Create a new {@link ExceptionController} instance. * @@ -88,10 +96,11 @@ public class ExceptionController extends AbstractErrorController { @ResponseBody public ResponseEntity> error(HttpServletRequest request) { Map body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL)); + String path = body.containsKey("path") ? body.get("path").toString() : "unknow path"; HttpStatus status = getStatus(request); ErrorResult errorResult = new ErrorResult(); errorResult.setType(NoHandlerFoundException.class.getName()); - errorResult.setMessage("No handler found for " + request.getMethod() + " " + body.get("path").toString()); + errorResult.setMessage("No handler found for " + request.getMethod() + " --> " + path); errorResult.setDate(new Date()); return new ResponseEntity<>(new RestResponse<>(status, errorResult), status); }