设置 Vaadin 会话超时参数 [英] Setting Vaadin session-timeout parameter

查看:54
本文介绍了设置 Vaadin 会话超时参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Vaadin 7.1.7,但我不知道如何设置 session-timeout参数(例如,1 分钟).

I am using Vaadin 7.1.7 and I can't figure out how to set session-timeout parameter (to, say, 1min).

据我所知,Vaadin 7.xx 不生成 web.xml,它使用 @VaadinServletConfiguration 注释但似乎没有 web.xml代码>会话超时参数.

As far as I can tell, Vaadin 7.x.x does not produce web.xml, it uses @VaadinServletConfiguration annotation but there doesn't seem to be a session-timeout parameter.

推荐答案

据我所知,在 Vaadin 7 中有 2 种设置会话超时的方法.

As far as I know there are 2 ways to set session-timeout in Vaadin 7.

在 web.xml 中:

In the web.xml:

<session-config>
    <session-timeout>1</session-timeout> <!-- 1 minute -->
</session-config>
<servlet>
    <servlet-name>MyServlet</servlet-name>
    <servlet-class>com.xyz.web.MyServlet</servlet-class>
    <init-param>
        <description>My Main Page</description>
        <param-name>UI</param-name>
        <param-value>com.xyz.web.MyUI</param-value>
    </init-param>
    <init-param>
        <description>Enable Session Timeout (heartbeat can't keep alive)</description>
        <param-name>closeIdleSessions</param-name>
        <param-value>true</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

或者我们可以通过编程方式设置(仅限当前会话):

Or we can set it programmatically (current session only):

VaadinSession.getCurrent().getSession().setMaxInactiveInterval(60); // 1 minute

似乎 servlet 3.0 注释没有帮助:link

It seems the servlet 3.0 annotations do not help: link

更多帮助:链接

这篇关于设置 Vaadin 会话超时参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆