mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-27 01:32:03 +08:00
优化防重复提交拦截器,接口请求非json数据不获取Body消息体
This commit is contained in:
parent
a78211ca00
commit
1efae4a588
@ -6,6 +6,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
@ -50,9 +51,14 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean isRepeatSubmit(HttpServletRequest request)
|
public boolean isRepeatSubmit(HttpServletRequest request)
|
||||||
|
{
|
||||||
|
String nowParams = "";
|
||||||
|
if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(),
|
||||||
|
MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||||
{
|
{
|
||||||
RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request;
|
RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request;
|
||||||
String nowParams = HttpHelper.getBodyString(repeatedlyRequest);
|
nowParams = HttpHelper.getBodyString(repeatedlyRequest);
|
||||||
|
}
|
||||||
|
|
||||||
// body参数为空,获取Parameter的数据
|
// body参数为空,获取Parameter的数据
|
||||||
if (StringUtils.isEmpty(nowParams))
|
if (StringUtils.isEmpty(nowParams))
|
||||||
|
Loading…
Reference in New Issue
Block a user