0

欢迎。我有一个登录过滤器,用于检查当前用户会话是否未过期。面孔配置:

 <filter>
        <filter-name>filter</filter-name>
        <filter-class>filter.LoginFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>filter</filter-name>
        <url-pattern>/protected/*</url-pattern>
    </filter-mapping> 
    <session-config>
        <session-timeout>
            1
        </session-timeout>
    </session-config>
    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/login.xhtml</location>
    </error-page> 

该过滤器仅适用于受保护文件夹中的页面。当会话到期时,转到页面 login.xhtml。我有几个站点没有受保护的文件夹,但这些页面上的会话也过期了。为什么?

4

1 回答 1

1

您唯一web.xml与会话生命周期有关的事情是

<session-config>
    <session-timeout>
        1
    </session-timeout>
</session-config>

将会话超时设置为一分钟。你有没有Filter一套并不重要。或者,用户是否已登录该站点。

session客户端是全局的即使客户端尚未显式登录(使用用户名和密码),也会被创建。只是登录后您在创建的session对象中设置了一些东西来验证客户端。

因此,当session过期时,它会全局过期,即对于您的 Web 应用程序的所有页面;他们是否在里面/protected并不重要。

于 2013-06-15T17:51:18.380 回答