Session 如何在SimpleTagSupport的doTag中访问会话
我有以下简单的代码:Session 如何在SimpleTagSupport的doTag中访问会话,session,servlets,Session,Servlets,我有以下简单的代码: public class MyTag extends SimpleTagSupport { public MyTag() { } public void doTag() throws IOException { //needs to access the session here. how? } } 我需要访问doTag()中的会话,以便在会话中注入值。我通过getJspContext()检查了SimpleTagSuppor
public class MyTag extends SimpleTagSupport {
public MyTag() {
}
public void doTag() throws IOException {
//needs to access the session here. how?
}
}
我需要访问doTag()中的会话,以便在会话中注入值。我通过getJspContext()检查了SimpleTagSupport的所有get方法和所有get方法。奇怪的是,我找不到访问会话的方法
我错过了什么吗?找到了答案。应该是:
getJspContext().setAttribute("attribute", "value", PageContext.SESSION_SCOPE);
希望这对其他人有帮助