java - 使用首选项可配置 Vaadin 会话超时
问题描述
当 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
解决方案
推荐阅读
- r - 将值列表分配到矩阵中,而不使用 R 在行或列中重复值
- hive - 覆盖同一个表时 Hive 上限条件不起作用
- r - 如何替换第一个事件中缺失的观测值的缺失值?
- wpf - Livechart winformssolidgague 厚度问题
- bash - 我可以在 bash 中按上下文排序吗?
- java - Switch case 不适用于 Java 中的 Enum
- ms-word - ApplyListTemplate 到 ParagraphFormat
- r - 如何在特定位置使用 R 在 excel 中插入新工作表?
- terminal - 在我的本地机器上查看 Gitlab CI/CD 管道
- powershell - 如何在 Windows PowerShell 中使用 .bat 文件更改当前目录?