【问题标题】:JSF 2 redirect to HTTPSJSF 2 重定向到 HTTPS
【发布时间】:2014-01-02 20:54:53
【问题描述】:

我看过这些帖子:Issues with JSF navigation rules using redirect on HTTPSJSF 2 and Post/Redirect/Get?,但我无法得到我想做的工作。我正在尝试使用 ConfigurableNavigationHandler 重定向到我的应用程序中的 https 页面。这是我的handleNavigation

public void handleNavigation(FacesContext context, String from, String outcome) {
  System.out.println("outcome: " + outcome);
  if (outcome.startsWith("manageEmail")) {
    outcome = "https://localhost:8081/appmonitor/faces/manageEmail.xhtml";
  }
  System.out.println("outcome: " + outcome);
  parent.handleNavigation(context, from, newOutcome);
}

当我点击重定向到“manageEmail”的链接时,我看到结果以“manageEmail”开头,并更改为我的 https 地址,但实际上并没有重定向到那里。我怀疑它试图导航到http://localhost:8080/appmonitor/faces/https://localhost:8081/appmonitor/faces/manageEmail.xhtml。如果这是实际发生的情况,有没有办法覆盖这种行为?

【问题讨论】:

    标签: jsf redirect jsf-2


    【解决方案1】:

    您是否尝试过访问外部响应并返回重定向命令?

    HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
    response.sendRedirect(outcome);
    

    【讨论】:

    • 我没有意识到我必须这样做。我以为parent.handleNavigation(context, from, newOutcome); 会为我解决这个问题。现在我知道了——谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-31
    • 2011-08-18
    • 1970-01-01
    • 2020-09-11
    • 2019-01-31
    • 2017-04-02
    相关资源
    最近更新 更多