JSF 2重定向到HTTPS

时间:2014-01-02 20:54:53

标签: jsf redirect jsf-2

我看过这些帖子: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。如果这实际上发生了什么,有没有办法覆盖这种行为?

1 个答案:

答案 0 :(得分:1)

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

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