不要用PageRedirectException进行跳转,Tapestry对这个异常的处理,是校验session的。下面是Tapestry处理PageRedirectException的代码,注意红色标注:
/**
* Handles {@link PageRedirectException} which involves executing
* {@link IRequestCycle#activate(IPage)} on the target page (of the exception), until either a
* loop is found, or a page succesfully activates.
* <p>
* This should generally not be overriden in subclasses.
*
* @since 3.0
*/
protected void handlePageRedirectException(IRequestCycle cycle, PageRedirectException exception)
throws IOException
{
List pageNames = new ArrayList();
String pageName = exception.getTargetPageName();
while (true)
{
if (pageNames.contains(pageName))
{
pageNames.add(pageName);
throw new ApplicationRuntimeException(EngineMessages.validateCycle(pageNames));
}
// Record that this page has been a target.
pageNames.add(pageName);
try
{
// Attempt to activate the new page.
cycle.activate(pageName);
break;
}
catch (PageRedirectException secondRedirectException)
{
pageName = secondRedirectException.getTargetPageName();
}
}
renderResponse(cycle);
}
你可以使用RedirectException进行跳转,Tapestry对这个异常的处理不校验session,如下:
/**
* Invoked when a {@link RedirectException} is thrown during the processing of a request.
*
* @throws ApplicationRuntimeException
* if an {@link IOException},{@link ServletException}is thrown by the redirect,
* or if no {@link RequestDispatcher}can be found for local resource.
* @since 2.2
*/
protected void handleRedirectException(IRequestCycle cycle, RedirectException redirectException)
{
String location = redirectException.getRedirectLocation();
if (LOG.isDebugEnabled())
LOG.debug("Redirecting to: " + location);
_infrastructure.getRequest().forward(location);
}
看到了吧?RedirectException是直接被request.forward的。

|