java获取token的常见三种方式
解决方法:
1.通过cookies
2.通过请求头
3.通过请求参数
String token =null;
Cookie[] cookies = request.getCookies();
if (cookies != null && cookies.length != 0) {
Cookie[] var = cookies;
int var2 = cookies.length;
for(int var3 = 0; var3 < var; ++var3) {
Cookie cookie = var[var3];
if (cookie.getName().equals("token")) {token =cookie.getValue();if (StringUtils.isEmpty(token)) {
}
}
token = request.getHeader("token");
if (StringUtils.isEmpty(token)) {
token = request.getParameter("token");
}
}