1

<redirect/在导航规则上使用 > 时遇到问题。我的应用程序在 HTTPS 上运行,并且当导航规则使用<redirect/> 时,重定向完成到 HTTP,而不是 HTTPS。有没有办法解决这个问题?

4

1 回答 1

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> 
于 2013-03-26T12:25:21.890 回答