2017-06-06 42 views
0

我有一個檢票(6.22)web應用程序。我需要執行自動重定向到外部URL。該方案將描述如下:Wicket 6.22自動重定向到外部URL

  1. 顧客在表單中輸入他們的數據
  2. 服務器處理幾個動作,並顯示結果頁面
  3. 結果頁面應持續5秒鐘,然後自動重定向用戶到外部網址。 結果頁面包含一個「返回」鏈接,因此客戶可以點擊該鏈接重定向到相同的外部URL。

我確實使用了 「renderHead」 功能添加標籤

<meta http-equiv="refresh" content="5; url=http://example.com">

的問題是,我需要重定向之前的會話無效。如果我這樣做,客戶將被重定向到ExpiredSession頁面而不是外部URL。

他們的任何干淨的解決方案,使它發生?

謝謝您的幫助

回答

0

而不是使用<meta http-equiv="refresh" content="5; url=http://example.com">,你可以建立一個Ajax行爲將:1)無效的會話; 2)重定向到外部頁面

anyComponent.add(new AbstractAjaxTimerBehavior(Duration.seconds(5)) { 
    @Override protected void onTimer(AjaxRequestTarget target) { 
     getSession().invalidate(); 
     throw new RedirectToUrlException("https://external.page"); 
    } 
});