我发现 Vaadin UI 变灰并变为非活动状态,并且未显示会话过期消息。此外,会话并不总是在 1 分钟后超时,我已将心跳设置为高于会话超时的值,因此会话应始终在心跳保持活动状态之前超时。
这是我与会话到期相关的配置和代码。
<context-param>
<param-name>heartbeatInterval</param-name>
<param-value>240</param-value>
</context-param>
<session-config>
<session-timeout>1</session-timeout>
</session-config>
<servlet>
<servlet-name>VaadinExample</servlet-name>
<servlet-class>com.example.VaadinExample</servlet-class>
<init-param>
<param-name>closeIdleSessions</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
在 VaadinExample servlet 中:
getService().setSystemMessagesProvider(
new SystemMessagesProvider() {
@Override
public SystemMessages getSystemMessages(
SystemMessagesInfo systemMessagesInfo) {
CustomizedSystemMessages messages =
new CustomizedSystemMessages();
messages.setSessionExpiredCaption("Session Expired");
messages.setSessionExpiredMessage("You have been inactive for over 30mins, click here to reload the application.");
messages.setSessionExpiredNotificationEnabled(true);
return messages;
}
});
有任何想法吗?