转 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>
分享到:
相关推荐
- 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 ...
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. * ...
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 ...
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 (project dependent). ...
- 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 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 ...
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...
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-...
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 ...
- **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....
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 ...
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 ...
* 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...
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...
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 (the Command-line compiler) causes an...
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 (the Command-line compiler) causes an...
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 ...
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 ...
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 ...
Note: could be a breaking change if selectors like: table > tr > td are used (to fix it use: table > tbody> tr > td ) [richtext] + table editing commands: insert/delete row/column, merge cell range,...