HttpSessionBinding session监听不到事件
public class HttpSessionBinding implements HttpSessionBindingListener {
public void valueBound(javax.servlet.http.HttpSessionBindingEvent e) {
String aa="";
}
public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent e) {
String aa="";
}
}
--------------web.xml----------------------
<listener>
<listener-class>femes.common.HttpSessionBinding</listener-class>
</listener>
----------------------------------------------
为什么监听不到事件?
问题点数:20、回复次数:7Top
1 楼doway(john)回复于 2006-03-04 18:44:06 得分 0
楼主用错了接口。
HttpSessionBindingListener 这个接口不需要在 web.xml 文件中加 listener,楼主可能应该用 HttpSessionActivationListener 接口。
Top
2 楼greki(锐╃→)回复于 2006-03-04 18:46:53 得分 0
HttpSessionActivationListener 需要加到web.xml里吗?
功能是为了实现.同一个用户ID不能同时登入.用什么接口好?Top
3 楼humanity(城市边缘的狼)回复于 2006-03-04 19:11:38 得分 0
实现 HttpSessionAttributeListener 接口。
查看 session: attributeAdd/Remove/Replace 事件。Top
4 楼doway(john)回复于 2006-03-04 19:37:48 得分 0
>功能是为了实现.同一个用户ID不能同时登入.用什么接口好?
不需要用特定的接口,也没有合适的接口。得自己编程处理,不是很好处理。
Top
5 楼greki(锐╃→)回复于 2006-03-04 19:38:20 得分 0
只要能监听到session过期的事件.就没问题了
...这么多接口.都有什么区别啊
Top
6 楼greki(锐╃→)回复于 2006-03-04 19:41:42 得分 0
现在我把已经登入的用户放到application里了,就是再用户session过期的时候的.application里的用户消不掉值.
(数据库用户表是老系统的.不能加表明是否已登入的列,不然也很好处理)Top
7 楼doway(john)回复于 2006-03-04 21:33:38 得分 20
javax.servlet.http
Interface HttpSessionListener
All Superinterfaces:
java.util.EventListener
--------------------------------------------------------------------------------
public interface HttpSessionListener
extends java.util.EventListener
Implementations of this interface may are notified of changes to the list of active sessions in a web application. To recieve notification events, the implementation class must be configured in the deployment descriptor for the web application.
Since:
v 2.3
See Also:
HttpSessionEvent
--------------------------------------------------------------------------------
Method Summary
void sessionCreated(HttpSessionEvent se)
Notification that a session was created.
void sessionDestroyed(HttpSessionEvent se)
Notification that a session was invalidated.
就是这个东西了,两个方法分别是在会话创建和过期时被调用。
Top




