【发布时间】:2013-03-26 12:02:09
【问题描述】:
在导航规则上使用<redirect/> 时遇到问题。我的应用程序在 HTTPS 上运行,并且当导航规则使用 <redirect/> 时,重定向完成到 HTTP,而不是 HTTPS。有没有办法解决这个问题?
【问题讨论】:
标签: java jsf redirect https navigation
在导航规则上使用<redirect/> 时遇到问题。我的应用程序在 HTTPS 上运行,并且当导航规则使用 <redirect/> 时,重定向完成到 HTTP,而不是 HTTPS。有没有办法解决这个问题?
【问题讨论】:
标签: java jsf redirect https navigation
您应该实现一个自定义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>
【讨论】: