Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session 获取和设置的不匹配 #13

Open
moods445 opened this issue Jun 21, 2019 · 4 comments
Open

session 获取和设置的不匹配 #13

moods445 opened this issue Jun 21, 2019 · 4 comments

Comments

@moods445
Copy link

/**
* 获取session属性信息中某个字段的值
*
* @param key
* 属性信息的key
* @return String 属性信息的值value
*/
protected String getSessionAttribute(final String key) {
return request.getSession().getAttributes().get(key);
}

/**
 * 设置session属性信息中某个字段的值
 * 
 * @param key
 *            属性信息的key
 * @param value
 *            属性信息的值value
 */
protected void setSessionAttribute(final String key, final String value) {
    session.getAttributes().put(key, value);
}
@moods445
Copy link
Author

/**
 * 清空session的属性信息
 */
protected void clearSessionAttribute() {
    session.getAttributes().clear();
}

@longger
Copy link
Contributor

longger commented Jun 21, 2019

请问可以详细的描述一下么?

@moods445
Copy link
Author

getSessionAttribute 是从 request.Session() 中获取 值,而
setSessionAttribute 是从 session中获取。
不是一个对象

@longger
Copy link
Contributor

longger commented Jun 24, 2019

getSessionAttribute 是获取request中的session属性;setSessionAttribute是向response中设置session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants