本文介紹了在 HTTPS 上使用重定向的 JSF 導航規則問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
在導航規則上使用 <redirect/
> 時遇到問題.我的應用程序在 HTTPS 上運行,當導航規則使用 <redirect/
> 時,重定向將執行到 HTTP,而不是 HTTPS.有沒有辦法解決這個問題?
I'm having issues when using <redirect/
> on navigation rules. My application works on HTTPS and when a navigation rule uses <redirect/
> the redirect is done to HTTP, not HTTPS. Is there any way to solve this?
推薦答案
你應該實現一個自定義 ConfigurableNavigationHandler
將根據操作源重新映射 URL(我在這里假設并非所有重定向都是到 https 目的地).舉個例子:
You should implement a custom ConfigurableNavigationHandler
that will remap the URL based on the source of the action (I'm assuming here that not all your redirects are to https destinations). As an example:
public class NavigationHandlerTest extends ConfigurableNavigationHandler {
private NavigationHandlerTest concreteHandler;
public NavigationHandlerTest(NavigationHandler concreteHandler) {
this.concreteHandler = concreteHandler;
}
@Override
public void handleNavigation(FacesContext context, String fromAction, String outcome)
{
//here, check where navigation is going to/coming from and based on that build an appropriate URL.
if(outcome.equals("someAction"){
outcome = "https://foo.bar.baz"; //set destination url
}
concreteHandler.handleNavigation(context, fromAction, outcome);
}
}
在faces-config.xml
<application>
<navigation-handler>com.example.NavigationHandlerTest</navigation-handler>
</application>
這篇關于在 HTTPS 上使用重定向的 JSF 導航規則問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!