我有基于Java的配置弹簧4,我的webAppIntializer实现了WebApplicationInitializer,我想在不使用web.xml的情况下实现会话超时我已经安装了以下类
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
public class SessionListener implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent event) {
System.out.println("==== Session is created ====");
event.getSession().setMaxInactiveInterval(5*60);
}
@Override
public void sessionDestroyed(HttpSessionEvent event) {
System.out.println("==== Session is destroyed ====");
}
}
并且在我的WebAppIntializer上我有super.onStartup
给我错误,因为它在WebApplicationInitializer
下找不到,而是AbstractAnnotationConfigDispatcherServletInitializer
我不想进行代码更改。是否有工作可以让我的会议时间为我工作。
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext); // this line is giving me error
servletContext.addListener(new SessionListener());
}
HELP !!!