Commit 1efae4a58889441b870fabb078209fede36d10ae
1 parent
a78211ca
优化防重复提交拦截器,接口请求非json数据不获取Body消息体
Showing
1 changed file
with
8 additions
and
2 deletions
ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
| ... | ... | @@ -6,6 +6,7 @@ import java.util.concurrent.TimeUnit; |
| 6 | 6 | import javax.servlet.http.HttpServletRequest; |
| 7 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | 8 | import org.springframework.beans.factory.annotation.Value; |
| 9 | +import org.springframework.http.MediaType; | |
| 9 | 10 | import org.springframework.stereotype.Component; |
| 10 | 11 | import com.alibaba.fastjson.JSONObject; |
| 11 | 12 | import com.ruoyi.common.constant.Constants; |
| ... | ... | @@ -51,8 +52,13 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor |
| 51 | 52 | @Override |
| 52 | 53 | public boolean isRepeatSubmit(HttpServletRequest request) |
| 53 | 54 | { |
| 54 | - RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request; | |
| 55 | - String nowParams = HttpHelper.getBodyString(repeatedlyRequest); | |
| 55 | + String nowParams = ""; | |
| 56 | + if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(), | |
| 57 | + MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE)) | |
| 58 | + { | |
| 59 | + RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request; | |
| 60 | + nowParams = HttpHelper.getBodyString(repeatedlyRequest); | |
| 61 | + } | |
| 56 | 62 | |
| 57 | 63 | // body参数为空,获取Parameter的数据 |
| 58 | 64 | if (StringUtils.isEmpty(nowParams)) | ... | ... |