【问题标题】:Some questions about view duration/life time关于查看持续时间/生命周期的一些问题
【发布时间】:2013-05-21 16:54:52
【问题描述】:

在我的 Web 项目中,大多数页面都使用 View Scoped 托管 bean。 它工作得很好,但有时,我注意到如果我离开页面一段时间,比如 10 分钟,当我返回页面时,页面中的所有内容都停止工作,并且服务器中没有显示控制台错误. 我认为这是由于生活的一种观点,但没有发现任何关于它的信息。 我在哪里可以找到有关它的信息? 有没有办法配置视图的生命周期?

我正在使用 apache tomcat 7。 下面是我的 web.xml 配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>AtualyGestao</display-name>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    <welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>home</param-value>
</context-param>

【问题讨论】:

    标签: jsf-2


    【解决方案1】:

    如果你在浏览器的开发者工具集中关注了ajax请求的HTTP响应应该会看到(在Chrome/Firebug/IE9中按F12):

    确实,会话已过期。关于为什么这是 JSF 的问题的详细解释可以在这个答案中找到:javax.faces.application.ViewExpiredException: View could not be restored

    JSF ajax 请求在出现异常时默认没有任何形式的反馈。如何解决此问题已在此处得到解答:Session timeout and ViewExpiredException handling on JSF/PrimeFaces ajax request

    【讨论】:

    • 但是没有生命周期配置?如果想要在失去会话之前让页面存活更长时间怎么办?
    • 这只是web.xml 中的标准 Servlet API 会话超时配置。另请参阅stackoverflow.com/questions/7449468/…。这进一步与 JSF 无关。
    猜你喜欢
    • 1970-01-01
    • 2011-05-16
    • 2011-05-18
    • 1970-01-01
    • 1970-01-01
    • 2021-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多