我在使用<redirect/
>导航规则时遇到问题。我的应用程序工作在HTTPS上,当一个导航规则使用<redirect/
>重定向到HTTP,而不是HTTPS。有办法解决这个问题吗?
你应该实现一个自定义的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>