struts2 session用4种方式哪种好

2025-06-25 02:42:29
推荐回答(3个)
回答1:

实现struts2的org.apache.struts2.interceptor.SessionAware接口
可以写一个BaseAction 然后每个action都继承它。这样可以直接使用
public void setSession(Map session){
this.session = session;
}

回答2:

实现Sessionxxxx接口的那个 Sessionxxxx(xxxx后面几个字母忘记了)。。

回答3:

ServletActionContext.getRequest().getSession();