|
|
@ -27,10 +27,16 @@ import java.util.List; |
|
|
@Component |
|
|
@Component |
|
|
public class UserInterceptor extends HandlerInterceptorAdapter { |
|
|
public class UserInterceptor extends HandlerInterceptorAdapter { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 定义不需要进行拦截的路由地址 |
|
|
|
|
|
*/ |
|
|
private static final List<String> pathList = new ArrayList<String>() { |
|
|
private static final List<String> pathList = new ArrayList<String>() { |
|
|
|
|
|
private static final long serialVersionUID = 4264670410720916937L; |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
add("/getMaterialAll"); |
|
|
add("/getMaterialAll"); |
|
|
add("/getCaptchaid"); |
|
|
add("/getCaptchaid"); |
|
|
|
|
|
add("/loginOut"); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
private static RedisTemplate<String, String> redisTemplate; |
|
|
private static RedisTemplate<String, String> redisTemplate; |
|
|
@ -47,12 +53,9 @@ public class UserInterceptor extends HandlerInterceptorAdapter { |
|
|
String token = null; |
|
|
String token = null; |
|
|
String servletPath = request.getServletPath(); |
|
|
String servletPath = request.getServletPath(); |
|
|
|
|
|
|
|
|
System.out.println(servletPath); |
|
|
System.out.println("访问地址"+servletPath); |
|
|
|
|
|
|
|
|
//如果是访问logout则删除对应的令牌
|
|
|
//如果是访问logout则删除对应的令牌
|
|
|
if ("/loginOut".equals(servletPath)) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
if (pathList.contains(servletPath)) { |
|
|
if (pathList.contains(servletPath)) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
@ -64,7 +67,6 @@ public class UserInterceptor extends HandlerInterceptorAdapter { |
|
|
userToken = (String) request.getSession().getAttribute("userToken"); |
|
|
userToken = (String) request.getSession().getAttribute("userToken"); |
|
|
} |
|
|
} |
|
|
if (userKey == null || userToken == null) { |
|
|
if (userKey == null || userToken == null) { |
|
|
// throw new MyException("未登录或登录过期,请重新登录");
|
|
|
|
|
|
userKey = ""; |
|
|
userKey = ""; |
|
|
} |
|
|
} |
|
|
token = redisTemplate.opsForValue().get(userKey); |
|
|
token = redisTemplate.opsForValue().get(userKey); |
|
|
|