2012-01-11 41 views
2

在我的Wicket 1.5 web应用程序中,我想重定向到另一个可书签页面,而原始页面的URL应保持为如何在保留原始网址的同时重定向到其他页面?

@MountPath(value="page1") 
public class WebPage1 extends WebPage { 

    public WebPage1() { 
     ... 
     if (!isDisplayable()) { 
      setResponsePage(WebPage2.class); 
      // throw new RestartResponseException(Error404WebPage.class); 
      // throw new RestartResponseAtInterceptPageException(Error404WebPage.class); 
     } 
    } 

    private boolean isDisplayable() { 
     boolean flag = ... 
     ... 
     return flag; 
    } 
} 

@MountPath(value="page2") 
public class WebPage2 extends WebPage { 

    public WebPage2() { 
    } 

    public WebPage2(PageParameters params) { 
    } 
} 

既不用setResponsePage(..)的方法中,抛出新RestartResponseException(..)或抛出新RestartResponseAtInterceptPageException(..)离开网址不变。 所有三种方法重定向到Page2 更改浏览器地址栏中显示的URL。

回答

0

您应该提供RestartResponseExceptionRedirectPolicy.NEVER_REDIRECT。即

throw new RestartResponseException(new PageProvider(Error404Page.class), RedirectPolicy.NEVER_REDIRECT); 
相关问题