我在使用 <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>
关于java - 在 HTTPS 上使用重定向的 JSF 导航规则问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15636609/