How to inject dependencies into HttpSessionListener, using Spring and without calls, like context.getBean("foo-bar")
?
相关问题
- java.lang.IllegalArgumentException: Cannot set to
- Spring Data MongoDB - lazy access to some fields
- Declaring an explict object dependency in Spring
- Decoding body parameters with Spring
- Spring Integration - Inbound file endpoint. How to
相关文章
- java JDK动态代理和cglib动态代理最后获取的代理对象都为null的问题
- org.xml.sax.SAXParseException; lineNumber: 7; colu
- SpringMVC如何把File封装到Map中?
- Spring: controller inheritance using @Controller a
- How to load @Configuration classes from separate J
- Java spring framework - how to set content type?
- Java/Spring MVC: provide request context to child
- Spring 5 Web Reactive - Hot Publishing - How to us
With Spring 4.0 but also works with 3, I implemented the example detailed below, listening to
ApplicationListener<InteractiveAuthenticationSuccessEvent>
and injecting theHttpSession
https://stackoverflow.com/a/19795352/2213375Since the Servlet 3.0 ServletContext has an "addListener" method, instead of adding your listener in your web.xml file you could add through code like so:
which means you can inject normally into the "MyHttpSessionListener" and with this, simply the presence of the bean in your application context will cause the listener to be registered with the container
You can declare your
HttpSessionListener
as a bean in Spring context, and register a delegation proxy as an actual listener inweb.xml
, something like this: