|
|
@@ -71,13 +71,15 @@ public class SSOInterceptor extends HandlerInterceptorAdapter {
|
|
|
*/
|
|
|
private void logSession(HttpServletRequest request) throws UnsupportedEncodingException {
|
|
|
Cookie[] cookies = request.getCookies();//这样便可以获取一个cookie数组
|
|
|
- for (Cookie cookie : cookies){
|
|
|
- if (cookie.getName().equals("user")) {
|
|
|
- Object jsonStr = cookie.getValue();
|
|
|
- if (jsonStr != null) {
|
|
|
- String str = URLDecoder.decode(jsonStr.toString(), HTTP.UTF_8);
|
|
|
- User user = JSONObject.parseObject(str, User.class);
|
|
|
- SystemSession.setUser(user);
|
|
|
+ if (!StringUtils.isEmpty(cookies)) {
|
|
|
+ for (Cookie cookie : cookies){
|
|
|
+ if (null != cookie && cookie.getName().equals("user")) {
|
|
|
+ Object jsonStr = cookie.getValue();
|
|
|
+ if (jsonStr != null) {
|
|
|
+ String str = URLDecoder.decode(jsonStr.toString(), HTTP.UTF_8);
|
|
|
+ User user = JSONObject.parseObject(str, User.class);
|
|
|
+ SystemSession.setUser(user);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|