使用HTTPS上的重定向的JSF导航规则的问题

时间:2013-03-26 12:02:09

标签: java jsf redirect https navigation

使用<redirect/&gt;时遇到问题关于导航规则。我的应用程序适用于HTTPS,当导航规则使用<redirect/&gt;时重定向是针对HTTP而不是HTTPS完成的。有什么方法可以解决这个问题吗?

1 个答案:

答案 0 :(得分:5)

您应该实现一个自定义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>