Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
RuoYi Vue
Commits
1bb6342b
Commit
1bb6342b
authored
Nov 22, 2022
by
RuoYi
Browse files
修复Log注解GET请求记录不到参数问题
parent
27acbe5b
Changes
3
Hide whitespace changes
Inline
Side-by-side
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java
View file @
1bb6342b
...
...
@@ -127,7 +127,7 @@ public class AjaxResult extends HashMap<String, Object>
/**
* 返回错误消息
*
* @return
* @return
错误消息
*/
public
static
AjaxResult
error
()
{
...
...
@@ -138,7 +138,7 @@ public class AjaxResult extends HashMap<String, Object>
* 返回错误消息
*
* @param msg 返回内容
* @return
警告
消息
* @return
错误
消息
*/
public
static
AjaxResult
error
(
String
msg
)
{
...
...
@@ -150,7 +150,7 @@ public class AjaxResult extends HashMap<String, Object>
*
* @param msg 返回内容
* @param data 数据对象
* @return
警告
消息
* @return
错误
消息
*/
public
static
AjaxResult
error
(
String
msg
,
Object
data
)
{
...
...
@@ -162,7 +162,7 @@ public class AjaxResult extends HashMap<String, Object>
*
* @param code 状态码
* @param msg 返回内容
* @return
警告
消息
* @return
错误
消息
*/
public
static
AjaxResult
error
(
int
code
,
String
msg
)
{
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java
View file @
1bb6342b
...
...
@@ -4,6 +4,10 @@ import java.io.IOException;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
...
...
@@ -68,6 +72,34 @@ public class ServletUtils
return
Convert
.
toBool
(
getRequest
().
getParameter
(
name
),
defaultValue
);
}
/**
* 获得所有请求参数
*
* @param request 请求对象{@link ServletRequest}
* @return Map
*/
public
static
Map
<
String
,
String
[]>
getParams
(
ServletRequest
request
)
{
final
Map
<
String
,
String
[]>
map
=
request
.
getParameterMap
();
return
Collections
.
unmodifiableMap
(
map
);
}
/**
* 获得所有请求参数
*
* @param request 请求对象{@link ServletRequest}
* @return Map
*/
public
static
Map
<
String
,
String
>
getParamMap
(
ServletRequest
request
)
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
for
(
Map
.
Entry
<
String
,
String
[]>
entry
:
getParams
(
request
).
entrySet
())
{
params
.
put
(
entry
.
getKey
(),
StringUtils
.
join
(
entry
.
getValue
(),
","
));
}
return
params
;
}
/**
* 获取request
*/
...
...
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
View file @
1bb6342b
...
...
@@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory;
import
org.springframework.stereotype.Component
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.HandlerMapping
;
import
com.alibaba.fastjson2.JSON
;
import
com.ruoyi.common.annotation.Log
;
import
com.ruoyi.common.core.domain.model.LoginUser
;
...
...
@@ -103,7 +102,6 @@ public class LogAspect
catch
(
Exception
exp
)
{
// 记录本地异常日志
log
.
error
(
"==前置通知异常=="
);
log
.
error
(
"异常信息:{}"
,
exp
.
getMessage
());
exp
.
printStackTrace
();
}
...
...
@@ -153,8 +151,8 @@ public class LogAspect
}
else
{
Map
<?,
?>
paramsMap
=
(
Map
<?,
?>)
ServletUtils
.
getRequest
().
getAttribute
(
HandlerMapping
.
URI_TEMPLATE_VARIABLES_ATTRIBUTE
);
operLog
.
setOperParam
(
StringUtils
.
substring
(
paramsMap
.
toString
(
),
0
,
2000
));
Map
<?,
?>
paramsMap
=
ServletUtils
.
getParamMap
(
ServletUtils
.
getRequest
()
);
operLog
.
setOperParam
(
StringUtils
.
substring
(
JSON
.
toJSONString
(
paramsMap
,
excludePropertyPreFilter
()
),
0
,
2000
));
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment