Session新增getString(key)方法,方便取值时类型转换

This commit is contained in:
shengzhang 2021-03-15 17:05:07 +08:00
parent 5808710bbf
commit aaf4bb8931

View File

@ -248,6 +248,19 @@ public class SaSession implements Serializable {
return getAttribute(key);
}
/**
* 从Session中取值转化为String类型
* @param key key
* @return
*/
public String getString(String key) {
Object value = getObject(key);
if(value == null) {
return null;
}
return String.valueOf(value);
}
/**
* 判断一个值是否为null
* @param value 指定值