public class ThreadLocalUtil {
private static ThreadLocal<User> thread = new ThreadLocal<>();
public static void setUser(User user) {
thread.set(user);
}
public static User getUser() {
return thread.get();
}
public static void remove() {
thread.remove();//清空数据
}
}
ThreadLocalUtil工具API
于 2023-04-27 11:04:00 首次发布