session容器是用来管理存到session里面的对象,而且也方便取出.
主要是为了管理方便. 实现了HttpSessionBindingListener的接口,可以对存入session和移出session做出监听.
java 代码
- package org.langsin.computer.web.core;
-
- import java.util.Locale;
-
- import javax.servlet.http.HttpSessionBindingEvent;
- import javax.servlet.http.HttpSessionBindingListener;
-
- import org.langsin.computer.vo.User;
-
- public class SessionContainer implements HttpSessionBindingListener {
- private User user;
- private Locale locale;
-
-
- public Locale getLocale() {
- return locale;
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- public User getUser() {
- return user;
- }
-
- public void setUser(User user) {
- this.user = user;
- }
- public void initialize(){
- user=new User();
- }
- public void cleanUp(){
- this.setUser(null);
- }
- public SessionContainer(){
- super();
- initialize();
- }
-
- public void valueBound(HttpSessionBindingEvent arg0) {
-
-
- }
-
- public void valueUnbound(HttpSessionBindingEvent arg0) {
-
-
- }
-
- }