获取全局id
package com.itheima.common;
public class BaseContext {
//session存储的id值无法在过滤器中获取到,要用ThreadLocal一次线程中都能获取
private static final ThreadLocal<Long> threadLocalId =new ThreadLocal<Long>();
public static void setThreadLocalId(Long id){
threadLocalId.set(id);
}
public static Long getThreadLocalId() {
Long aLong = threadLocalId.get();
return aLong;
}
}
浙公网安备 33010602011771号