色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

java session出現(xiàn)的錯誤

復(fù)制代碼 代碼如下:
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 接口的方法實現(xiàn)了,但是在類的實現(xiàn)時忘記寫它了,我在Session進(jìn)行添加時要是添加不進(jìn)去,我找了好久,又沒錯誤,又測試了很多遍,就是添加時的監(jiān)聽沒有用,我以為我方法寫錯了,我一個字母的對了幾遍,還是沒發(fā)現(xiàn)。呵呵,在后來,我又看了前面的例子,突然之間就發(fā)現(xiàn)了,我這好像少了點什么,才加上去,一下了,好了。做程序真得細(xì)心呀。

jsp技術(shù)java session出現(xiàn)的錯誤,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 乐清市| 荃湾区| 湘阴县| 德江县| 赣榆县| 龙井市| 兰坪| 玉山县| 尉犁县| 东明县| 芜湖市| 安仁县| 根河市| 五家渠市| 固始县| 无锡市| 子长县| 三河市| 苍梧县| 大姚县| 富裕县| 无为县| 会理县| 仁寿县| 齐齐哈尔市| 青海省| 莱阳市| 修水县| 灵石县| 阳泉市| 定西市| 荥阳市| 通河县| 连南| 繁昌县| 嵩明县| 孙吴县| 三门峡市| 谢通门县| 元氏县| 泽库县|