提交 090baafc 编写于 作者: 爱吃血肠's avatar 爱吃血肠

优化LoginContext类

上级 82f1b9b6
......@@ -7,11 +7,11 @@ package com.yingjun.ssm.util;
*/
public class LoginContext {
private ThreadLocal<LoginContext> threadLocal = new ThreadLocal<>();
private static final ThreadLocal<LoginContext> holder = new ThreadLocal<>();
/**
* 主键id
*/
private Long id;
private final long id;
/**
* 密码
*/
......@@ -25,19 +25,24 @@ public class LoginContext {
*/
private String email;
/**
* 移除当前线程中的变量值
*/
public void remove(){
threadLocal.remove();
public LoginContext(long id){
super();
this.id = id;
}
public Long getId() {
return id;
public static LoginContext getHolder() {
return holder.get();
}
public void setId(Long id) {
this.id = id;
public static void setHolder(LoginContext loginContext) {
holder.set(loginContext);
}
public static void remove(){
holder.remove();
}
public long getId() {
return id;
}
public String getPassword() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册