Java 会话已过期

Java 会话已过期,java,web-applications,session-timeout,Java,Web Applications,Session Timeout,欢迎光临。我有一个登录筛选器,用于检查当前用户会话是否已过期。faces配置: <filter> <filter-name>filter</filter-name> <filter-class>filter.LoginFilter</filter-class> </filter> <filter-mapping> <filter-name&g

欢迎光临。我有一个登录筛选器,用于检查当前用户会话是否已过期。faces配置:

 <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> 

滤波器
filter.LoginFilter
滤波器
/保护/*
1.
javax.faces.application.ViewExpiredException
/login.xhtml

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

您的
web.xml
中唯一与会话生存期有关的是

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

1.
将会话超时设置为一分钟。是否设置了
过滤器
无关紧要。或者,用户是否已登录该站点

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

因此,当
会话
过期时,它将全局过期,即对web应用程序的所有页面过期;它们是否在
/protected
内并不重要。

这不是faces-config.xml文件,而是web.xml文件。