## 网站开发 用监听器写 用户登录日志功能 我用的是 ssm框架
遇见问题:
在监听器中注入类出错
原本通过注入 框架会帮我实例化的类 结果是null
看了下面的文档解决了
https://www.cnblogs.com/fengli9998/p/6542829.html
新建一个类继承这三个接口:HttpSessionListener 、ServletRequestListener、HttpSessionAttributeListener
```
public class UserLoginListener implements HttpSessionListener,ServletRequestListener,HttpSessionAttributeListener{
//直接注入空指针
/*@Autowired
private UserLogService userLogService;*/
private String ipAddress;
private String userAgent;
UserLogService userLogService ;
/*private String type;//1-登出 0-登入
private String userName;*/
//这里保存的是最后登录 用户 的信息
//HttpSessionListener
public void sessionCreated(HttpSessionEvent se) {
if (userLogService==null) {userLogService=WebApplicationContextUtils.getWebApplicationContext(se.getSe