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>