只对json类型请求构建可重复读取inputStream的request

master
RuoYi 5 years ago
parent eec5c58b4a
commit 1a079532e8
  1. 5
      ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java

@ -8,6 +8,8 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.http.MediaType;
import com.ruoyi.common.utils.StringUtils;
/** /**
* Repeatable 过滤器 * Repeatable 过滤器
@ -27,7 +29,8 @@ public class RepeatableFilter implements Filter
throws IOException, ServletException throws IOException, ServletException
{ {
ServletRequest requestWrapper = null; ServletRequest requestWrapper = null;
if (request instanceof HttpServletRequest) if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(),
MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE))
{ {
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
} }

Loading…
Cancel
Save