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

jac*_*elo 1 java navigation https jsf redirect

<redirect/在导航规则上使用> 时遇到问题.我的应用程序适用于HTTPS,当导航规则使用<redirect/>重定向到HTTP,而不是HTTPS.有什么方法可以解决这个问题吗?

kol*_*sus 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);   

 }


   } 
Run Code Online (Sandbox Code Playgroud)

faces-config.xml中注册您的实现

     <application>
        <navigation-handler>com.example.NavigationHandlerTest</navigation-handler>
     </application> 
Run Code Online (Sandbox Code Playgroud)