国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

java session出現的錯誤

2024-09-05 00:21:03
字體:
來源:轉載
供稿:網友
好郁悶哦,搞了兩個多小時,我把先把HttpSessionAttributeListener 接口的方法實現了

復制代碼 代碼如下:


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進行添加時要是添加不進去,我找了好久,又沒錯誤,又測試了很多遍,就是添加時的監聽沒有用,我以為我方法寫錯了,我一個字母的對了幾遍,還是沒發現。呵呵,在后來,我又看了前面的例子,突然之間就發現了,我這好像少了點什么,才加上去,一下了,好了。做程序真得細心呀。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 个旧市| 获嘉县| 乌拉特后旗| 丹阳市| 双流县| 兰考县| 永善县| 沾化县| 潞城市| 武鸣县| 定襄县| 宁乡县| 新巴尔虎左旗| 德格县| 祁连县| 东丰县| 漳州市| 泗水县| 茌平县| 长子县| 武宣县| 沂水县| 竹溪县| 永康市| 台中县| 雅安市| 申扎县| 延庆县| 颍上县| 望谟县| 营口市| 诸暨市| 铜山县| 茶陵县| 喀喇沁旗| 三门县| 江川县| 新津县| 星子县| 绥德县| 新巴尔虎右旗|