查看请求ip

This commit is contained in:
dinggang 2022-06-15 14:11:18 +08:00
parent c31ea91477
commit 848f507b13
1 changed files with 4 additions and 0 deletions

View File

@ -6,6 +6,8 @@ import io.renren.common.exception.RenException;
import io.renren.entity.TokenEntity;
import io.renren.service.TokenService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
@ -24,10 +26,12 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
private TokenService tokenService;
public static final String USER_KEY = "userId";
public static final Logger LOGGER = LoggerFactory.getLogger(AuthorizationInterceptor.class);
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Login annotation;
LOGGER.info("请求地址:{}", request.getRemoteAddr());
if(handler instanceof HandlerMethod) {
annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class);
}else{