java中session出现的错误
来源:互联网 发布:mobi手机域名 编辑:程序博客网 时间:2024/05/22 15:01
package cn.lang.any.listener;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class AmpList implements
ServletContextListener,HttpSessionListener,HttpSessionAttributeListener
{
private ServletContext application=null;
public void contextInitialized(ServletContextEvent sce)
{
this.application=sce.getServletContext();
this.application.setAttribute("alluser",new ArrayList());
//System.out.println("初始化****");
}
public void sessionCreated(HttpSessionEvent se)
{
//System.out.println("session ****");
}
public void sessionDestroyed(HttpSessionEvent se)
{
List l=(List)this.application.getAttribute("alluser");
String value=(String)se.getSession().getAttribute("uname");
l.remove(value);
this.application.setAttribute("alluser",l);
}
public void attributeAdded(HttpSessionBindingEvent se)
{
//System.out.println("Hello");
List lis=(List)this.application.getAttribute("alluser");
lis.add(se.getValue());
this.application.setAttribute("alluser",lis);
}
public void attributeRemoved(HttpSessionBindingEvent se)
{
}
public void attributeReplaced(HttpSessionBindingEvent se)
{
}
public void contextDestroyed(ServletContextEvent sce)
{}
}
好郁闷哦,搞了两个多小时,我把先把HttpSessionAttributeListener 接口的方法实现了,但是在类的实现时忘记写它了,我在Session进行添加时要是添加不进去,我找了好久,又没错误,又测试了很多遍,就是添加时的监听没有用,我以为我方法写错了,我一个字母的对了几遍,还是没发现。呵呵,在后来,我又看了前面的例子,突然之间就发现了,我这好像少了点什么,才加上去,一下了,好了。做程序真得细心呀。
- java中session出现的错误
- 使用hibernate2的时候出现session中对象重复错误
- 今天调试项目dwr中出现session error的错误
- dwr 出现session error错误的解决方法
- dwr 出现session error错误的处理
- ashx页面中 Session值出现“未将对象引用设置到对象的实例”错误
- ashx页面中 Session值出现“未将对象引用设置到对象的实例”错误
- ashx页面中 Session值出现“未将对象引用设置到对象的实例”错误
- phpmyadmin中出现错误Cannot start session without errors
- 针对java web开发中出现错误的总
- JAVA中出现错误:编码GBK的不可映射字符
- 关于java中出现Unreachable code 编译错误的问题
- Java 项目JDBC 链接数据库中会出现的错误
- ssh中出现no session的问题
- struts2 中出现的错误
- eclipse中出现的错误
- IOS9中出现的错误
- hibernate中出现的错误
- 测试团队中,是否需要注重测试人员的感受呢?
- struts2学习笔记(四)
- Chinese in Debian——Debian 下的中文设置
- μC/OS-II在C8051F上的移植
- getline函数的一点瓜葛
- java中session出现的错误
- 餐饮业已经迈入CRM的转折之路
- 关于BlackBerry API的使用
- 午夜惊魂
- SQL 2005导出EXCEL
- 在wxPython中使用OpenGL
- 吸血鬼数字的算法
- log4j输出到系统日志,邮件
- IT技术员职业生涯的红色警报