【问题标题】:Issues with JSF navigation rules using redirect on HTTPS在 HTTPS 上使用重定向的 JSF 导航规则问题
【发布时间】:2013-03-26 12:02:09
【问题描述】:

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

【问题讨论】:

    标签: java jsf redirect https navigation


    【解决方案1】:

    您应该实现一个自定义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-10-22
      • 1970-01-01
      • 2013-09-01
      • 2011-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-05
      相关资源
      最近更新 更多