Skip to content

Commit

Permalink
防重复提交标识组合(key + url + header)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzongzhuan committed Dec 30, 2021
1 parent 69fc2cf commit bdab124
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,12 @@ public boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotatio

// 请求地址(作为存放cache的key值)
String url = request.getRequestURI();

// 唯一值(没有消息头则使用请求地址)
String submitKey = request.getHeader(header);
if (StringUtils.isEmpty(submitKey))
{
submitKey = url;
}
String submitKey = StringUtils.trimToEmpty(request.getHeader(header));

// 唯一标识(指定key + 消息头)
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey;
// 唯一标识(指定key + url + 消息头)
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + url + submitKey;

Object sessionObj = redisCache.getCacheObject(cacheRepeatKey);
if (sessionObj != null)
Expand Down

0 comments on commit bdab124

Please sign in to comment.