当UI闲置3分钟以上时,我正在使用Vaadin 8和附加插件来实现会话超时。这是附加插件
<dependency>
<groupId>org.vaadin.anna</groupId>
<artifactId>cleanupservlet</artifactId>
<version>2.0.0</version>
</dependency>
VaadinUI.java
@Override
protected void init(VaadinRequest vaadinRequest) {
// timeout for 3 mins
VaadinSession.getCurrent().getSession().setMaxInactiveInterval(180);
Responsive.makeResponsive(this);
setLocale(vaadinRequest.getLocale());
showMainView();
}
VaadinServlet.java
@WebServlet(urlPatterns = "/*", name = "VaadinServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = VaadinServlet.class, productionMode = false, heartbeatInterval = 180, closeIdleSessions = true)
public static class VaadinServlet extends CleanupServlet {
@Override
protected int getCleanupPollingInterval() {
// how long to wait between session timeout checks
return 2000;
}
@Override
protected boolean alwaysCheckUITimeOuts() {
// if you want to ensure UI cleanup on every check
// regardless of session timeout, default false
return true;
}
}
我没有web.xml来配置inactiveInterval。有没有一种方法可以配置用户在“首选项”对话框中给定的inactiveInterval和heartbeatInterval?
或者有什么方法可以实现可由用户配置的会话超时?
感谢您的帮助。
TIA