优化防重复提交拦截器,请求没有消息头则使用地址

This commit is contained in:
RuoYi 2020-08-11 11:24:55 +08:00
parent 71ec44a545
commit ad4df6245d

View File

@ -70,8 +70,15 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
// 请求地址作为存放cache的key值 // 请求地址作为存放cache的key值
String url = request.getRequestURI(); String url = request.getRequestURI();
// 唯一值没有消息头则使用请求地址
String submitKey = request.getHeader(header);
if (StringUtils.isEmpty(submitKey))
{
submitKey = url;
}
// 唯一标识指定key + 消息头 // 唯一标识指定key + 消息头
String cache_repeat_key = Constants.REPEAT_SUBMIT_KEY + request.getHeader(header); String cache_repeat_key = Constants.REPEAT_SUBMIT_KEY + submitKey;
Object sessionObj = redisCache.getCacheObject(cache_repeat_key); Object sessionObj = redisCache.getCacheObject(cache_repeat_key);
if (sessionObj != null) if (sessionObj != null)