JavaBean objects that implement the Httpsessionactivationlistener interface can perceive their own activated and passivated events
The Web server calls the following method Sessionwillpassivate (Httpsessionbindingevent Event) method when the object bound to the HttpSession object is going to be passivated with the HttpSession object:
When the object bound to the HttpSession object is to be activated with the HttpSession object, the Web server calls the object's void Sessiondidactive (Httpsessionbindingevent event) method
<Manager className="org.apache.catalina.session.PersistentManager" maxIdleSwap="1"><Store className="org.apache.catalina.session.FileStore" directory="itcast"/></Manager></Context>注意:/META-INF/context.xml
package cn.vote.domain;import javax.servlet.http.HttpSessionActivationListener;import javax.servlet.http.HttpSessionEvent;/** JavaBean对象,感知自已何时被钝化,何时被激活,由Web容器决定 */public class Student implements HttpSessionActivationListener { private String username; public Student() { } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public void sessionDidActivate(HttpSessionEvent se) { } public void sessionWillPassivate(HttpSessionEvent se) { }}
Httpsessionactivationlistener Interface Learning Notes