|
|
@@ -1,13 +1,6 @@
|
|
1
|
1
|
package com.ruoyi.common.security.handler;
|
|
2
|
2
|
|
|
3
|
|
-import com.ruoyi.common.core.constant.HttpStatus;
|
|
4
|
|
-import com.ruoyi.common.core.exception.DemoModeException;
|
|
5
|
|
-import com.ruoyi.common.core.exception.InnerAuthException;
|
|
6
|
|
-import com.ruoyi.common.core.exception.ServiceException;
|
|
7
|
|
-import com.ruoyi.common.core.exception.auth.NotPermissionException;
|
|
8
|
|
-import com.ruoyi.common.core.exception.auth.NotRoleException;
|
|
9
|
|
-import com.ruoyi.common.core.utils.StringUtils;
|
|
10
|
|
-import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
3
|
+import javax.servlet.http.HttpServletRequest;
|
|
11
|
4
|
import org.slf4j.Logger;
|
|
12
|
5
|
import org.slf4j.LoggerFactory;
|
|
13
|
6
|
import org.springframework.validation.BindException;
|
|
|
@@ -17,7 +10,16 @@ import org.springframework.web.bind.MissingPathVariableException;
|
|
17
|
10
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
18
|
11
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
19
|
12
|
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
|
20
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
13
|
+import com.ruoyi.common.core.constant.HttpStatus;
|
|
|
14
|
+import com.ruoyi.common.core.exception.DemoModeException;
|
|
|
15
|
+import com.ruoyi.common.core.exception.InnerAuthException;
|
|
|
16
|
+import com.ruoyi.common.core.exception.ServiceException;
|
|
|
17
|
+import com.ruoyi.common.core.exception.auth.NotPermissionException;
|
|
|
18
|
+import com.ruoyi.common.core.exception.auth.NotRoleException;
|
|
|
19
|
+import com.ruoyi.common.core.text.Convert;
|
|
|
20
|
+import com.ruoyi.common.core.utils.StringUtils;
|
|
|
21
|
+import com.ruoyi.common.core.utils.html.EscapeUtil;
|
|
|
22
|
+import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
21
|
23
|
|
|
22
|
24
|
/**
|
|
23
|
25
|
* 全局异常处理器
|
|
|
@@ -91,8 +93,13 @@ public class GlobalExceptionHandler
|
|
91
|
93
|
public AjaxResult handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request)
|
|
92
|
94
|
{
|
|
93
|
95
|
String requestURI = request.getRequestURI();
|
|
|
96
|
+ String value = Convert.toStr(e.getValue());
|
|
|
97
|
+ if (StringUtils.isNotEmpty(value))
|
|
|
98
|
+ {
|
|
|
99
|
+ value = EscapeUtil.clean(value);
|
|
|
100
|
+ }
|
|
94
|
101
|
log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e);
|
|
95
|
|
- return AjaxResult.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), e.getValue()));
|
|
|
102
|
+ return AjaxResult.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), value));
|
|
96
|
103
|
}
|
|
97
|
104
|
|
|
98
|
105
|
/**
|