`
zhousuying
  • 浏览: 118999 次
  • 性别: Icon_minigender_2
  • 来自: 济南
文章分类
社区版块
存档分类
最新评论

could not be restored

阅读更多
转 http://hi.baidu.com/h2opo/blog/item/95c6c2fdd8f0c940d7887d64.html
avax.servlet.ServletException: viewId:/login.jsp - View /login.jsp could not be restored. javax.faces.webapp.FacesServlet.service(FacesServlet.java:249) root cause javax.faces.application.ViewExpiredException: viewId:/login.jsp - View /login.jsp could not be restored. com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:185) com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)

出现这个错误是因为session 超时。当然关掉页面重新打开就不会有这个问题,但是在可用性方面就很差。作为开发人员看见这个错误会知道为什么,普通浏览者肯定会觉得出了什么问题。所以还是解决一下好。

如果是 sun appplication server

解决办法是在web.xml中添加
<error-page>
     <exception-type>javax.faces.application.ViewExpiredException</exception-type>
     <location>/sessionExpired.jsp</location>
</error-page>

sessionExpired.jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="http://java.sun.com/jstl/core" divfix="c"%>
<c:redirect url="/login.jsf" />

如果web容器是tomcat,解决办法如下:

package com.jsf.util;

import javax.faces.FacesException;
import javax.faces.application.ViewExpiredException;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;

import com.sun.faces.lifecycle.LifecycleImpl;

public class TeleLifecycleImpl extends LifecycleImpl
{
public TeleLifecycleImpl()
{
   super();
}

public void execute(FacesContext context)
{
   try
   {
    super.execute(context);
   }
   catch (ViewExpiredException vee)
   {
    redirect(context);
   }
   catch (FacesException fe)
   {
    throw fe;
   }
}

private void redirect(FacesContext context)
{
   try
   {
    context.responseComplete();
    context.renderResponse();
    HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
    String url = context.getExternalContext().getRequestContextPath() + "/faces/error.jsp";
    response.sendRedirect(url);
   }
   catch (Exception e)
   {
    System.out.println("url redirect wrong ");
   }

}
}

在jsf配置文件 faces-config.xml 中添加如下内容

<factory>
     <lifecycle-factory>trackingmap.TeleLifecycleFactoryImpl</lifecycle-factory>
</factory>

在web.xml 中添加如下内容

<context-param>
     <param-name>javax.faces.LIFECYCLE_ID</param-name>
    <param-value>TELEEPOCH</param-value>
</context-param>
分享到:
评论
1 楼 csuhitzzx 2011-03-27  
报错
java.lang.ClassCastException: com.jsfabc.jsh.utils.TeleLifecycleImpl

相关推荐

    EditPlus.5.0.777 64位 中文版

    - Fixes an issue in the previous build where Output Window size could not be restored when located at the right side. - Fixes sftp connection issues on some servers. - Fixes an issue in the previous ...

    EditPlus v2.31 fixpack

    Highlighed matching braces could not be restored when changing focus. * 'Save wrapped lines with CR/LF' option could corrupt file. * Replace dialog box with regex did not work upward. * ...

    plsqldev12.0.3.1821x64主程序+ v12中文包+keygen

    when docking a notebook) the PL/SQL Developer Window would be restored when minimized, and the minimize button did not work Text Importer field selection list size optimized + pre-select next field ...

    JLink_Windows_V648.zip

    Analog Devices ADUCM355: Reset could not be overwritten using a J-Link script file. Fixed. CCS plugin: Added a new option which allows configuring a J-Link script file &#40;project dependent&#41;. ...

    BURNINTEST--硬件检测工具

    - Corrected a bug, where in rare cases, the result summary could be duplicated in a log file. - Updated license management, in an attempt to remove a rare crash on startup. Release 5.3 build 1012....

    VclZip pro v3.10.1

    VCLZip Native Delphi Zip/UnZip Component!...Fixed a problem that was not allowing ZipComment's to be added correctly to spanned or blocked zip files. Not the same fix as in 2.22. Directories ...

    微软内部资料-SQL性能优化2

    Assuming the page reference does not result in an access violation, a page fault can be either hard or soft. A hard page fault results in a read from disk, either a page file or memory-mapped file. A...

    WinRAR_4 00_Beta_3_SC 附精美主题

    So \\server\share will be converted to __server\share when archiving and restored to the original \\server\share when extracting with -ep3. 2. Bugs fixed: a) previous beta could fail to unpack self-...

    acpi控制笔记本风扇转速

    could be incorrectly generated if the parent ResourceTemplate pathname places the template within a different namespace scope than the current scope. (BZ 7212) Fixed a problem where the compiler ...

    CCDE 400-007-en-unlocked.pdf

    - **Replication Type:** Synchronous data replication might be necessary to meet the business requirements, while asynchronous replication could be used to avoid performance impact on the primary site....

    曲线拟合工具CurveExpert 1.0

    restored the next time CurveExpert runs Bug Fixes: + Whoops! The new file reading procedure masked out all minus and minus signs in the data, so that numbers like -10 and 10e-3 were not read ...

    STG (SNMP Traffic Grapher)

    Also STG could be useful during network problems troubleshooting. It runs on MS Windows 2000, Windows NT 4.0, Windows 98 and Windows Millenium. To run it on WinNT 4.0 you may need mgmtapi.dll and ...

    eac3to V3.17

    * fixed: error code not set for "source file format could not be detected" * fixed: audio resampling from/to 24.975 didn't work properly * fixed: WAV files beginning with lots of zeroes were sometimes...

    a project model for the FreeBSD Project.7z

    This project model is not meant to be a tool to justify creating impositions for developers, but as a tool to facilitate coordination. It is meant as a description of the project, with an overview of...

    Turbo C++ 3.0[DISK]

    some things you may want to save could be overwritten, review the following items to make sure you don't lose important information: 1. Selecting CMD &#40;the Command-line compiler&#41; causes an...

    Turbo C++ 3.00[DISK]

    some things you may want to save could be overwritten, review the following items to make sure you don't lose important information: 1. Selecting CMD &#40;the Command-line compiler&#41; causes an...

    Turbo C 2.01[DISK]

    restored each time the screen is swapped. In general, you don't need to use this switch unless your program modifies the EGA palette registers, or unless your program uses BGI to change the ...

    CE中文版-启点CE过NP中文.exe

    Memory Scan: Fixed a rare situation that could cause an error Memory Scan: Simple values now works with groupscan Memory Scan Lua: Scanfiles now also get deleted if the memory scan object is freed ...

    Turbo C 2.00[DISK]

    restored each time the screen is swapped. In general, you don't need to use this switch unless your program modifies the EGA palette registers, or unless your program uses BGI to change the ...

    sciter-sdk-4.0.3.5348

    Note: could be a breaking change if selectors like: table &gt; tr &gt; td are used (to fix it use: table &gt; tbody&gt; tr &gt; td ) [richtext] + table editing commands: insert/delete row/column, merge cell range,...

Global site tag (gtag.js) - Google Analytics