/**
* 用ThreadLocal来存储Session,以便实现Session any where.
*
*/
public class ThreadLocalUtil {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
private static ThreadLocal<HttpSession> httpSessionThreadLocal = new ThreadLocal<HttpSession>();
public static HttpSession getHttpSessionThreadLocal() {
return ThreadLocalUtil.httpSessionThreadLocal.get();
}
public static void setHttpSessionThreadLocal(HttpSession httpSession) {
ThreadLocalUtil.httpSessionThreadLocal.set(httpSession);
}
public static void remove() {
ThreadLocalUtil.httpSessionThreadLocal.remove();
}
}
标签:存储,ThreadLocalUtil,ThreadLocal,Session,static,public,httpSessionThreadLocal From: https://www.cnblogs.com/wangyu19900123/p/16995621.html