1
qinxi 2022-07-08 10:41:53 +08:00
参考 CommonsRequestLoggingFilter
核心由 AbstractRequestLoggingFilter 提供 |
2
LeegoYih 2022-07-08 10:46:18 +08:00
用拦截器吧
新建一个类,实现`HandlerInterceptor`接口: ```java public class FooHandlerInterceptor implements HandlerInterceptor { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { // TODO return true; } public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { // TODO } public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { // TODO } } ``` 新建一个配置类,实现`WebMvcConfigurer`接口,重写`addInterceptors`方法,将拦截器注册到 Spring MVC 容器中: ``` @Configuration public class FooConfiguration implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new FooHandlerInterceptor()).addPathPatterns("/**"); } } ``` |
3
wolfie 2022-07-08 10:47:37 +08:00
贴代码
|
4
tmdbbr 2022-07-08 10:56:25 +08:00
有意思 我看看我们咋个解决得
|
5
fiveStarLaoliang 2022-07-08 10:56:50 +08:00
|
6
chendy 2022-07-08 11:06:15 +08:00
歪个楼,新系统新前端框架下,xss 过滤还有必要么?……
|
8
wolfie 2022-07-08 13:53:06 +08:00
流的可重复读取,提现在哪里。
javax.servlet.ServletRequestWrapper#getInputStream |
10
wolfie 2022-07-08 14:11:39 +08:00
每次调用 XssHttpServletRequest#getInputStream ,都会调用 super#getInputStream 啊
|
11
goalidea 2022-07-10 09:42:19 +08:00 1
应该出在 `XssHttpServletRequest.getInputStream()` 中的 `final ByteArrayInputStream bais = new ByteArrayInputStream(inputHandlers(super.getInputStream()).getBytes());` 这行代码。
|