是否可以将Session Listener(HttpSessionListener的实现)注册为Spring Bean。 我的工作实现将侦听器添加到BootStrap.groovy中的servlet上下文中
def init = { servletContext -> servletContext.addListener(userLoginSessionListener) }
但这会导致我的集成测试失败,并出现UnsupportedOperationException(将为此创建另一个问题)
现在我在resources.groovy中有以下内容
userLoginSessionListener(UserLoginSessionListener)
但现在我的sessionCreated和sessionDestroyed方法不再被触发。
不得不走老路。 删除了bean定义和BootStrap。groovy配置并通过_Events中的eventWebXmlEnd处理程序添加监听器。groovy在我们的集成测试中表现良好。
<listener> <listener-class>com.example.UserLoginSessionListener</listener-class> </listener>