0
我在導航規則上使用<redirect/
>時遇到問題。我的應用程序在HTTPS上工作,並且當導航規則使用<redirect/
>重定向完成到HTTP,而不是HTTPS。有什麼辦法可以解決這個問題嗎?在HTTPS上使用重定向的JSF導航規則問題
我在導航規則上使用<redirect/
>時遇到問題。我的應用程序在HTTPS上工作,並且當導航規則使用<redirect/
>重定向完成到HTTP,而不是HTTPS。有什麼辦法可以解決這個問題嗎?在HTTPS上使用重定向的JSF導航規則問題
你應該實現一個自定義的ConfigurableNavigationHandler
,它將根據動作來源重新映射URL(我假設這裏並不是所有的重定向都是https目的地)。舉個例子:
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>