【发布时间】:2014-01-03 13:48:35
【问题描述】:
我在测试服务器上的应用程序仅通过 https 执行。当我在不重定向的情况下导航时,它可以完美运行:
例子:
<p:menuitem value="#{msg.customerScreen}" url="/restrict/customer.xhtml" />
<p:menuitem value="#{msg.productScreen}" url="/restrict/product.xhtml" />
但是当我需要重定向到另一个页面时,它会重定向到 http 而不是 https。通过 http 使用时,它可以完美运行:
<p:commandLink ajax="false" action="/commerce/store.xhtml?faces-redirect=true">
<h:graphicImage library="images/BTN" name="btn_to_shop.gif"/>
</p:commandLink>
作为一种解决方法,我尝试重建 URL:
<p:commandLink ajax="false" action="#{authorizerBean.getCompleteURL('/commerce/store.xhtml?faces-redirect=true')}">
<h:graphicImage library="images/BTN" name="btn_to_shop.gif"/>
</p:commandLink>
public String getCompleteURL(String page) {
try {
FacesContext ctxt = FacesContext.getCurrentInstance();
ExternalContext ext = ctxt.getExternalContext();
URI uri = new URI(ext.getRequestScheme(), null, ext.getRequestServerName(), ext.getRequestServerPort(), ext.getRequestContextPath(), null, null);
return uri.toASCIIString() + page;
} catch (URISyntaxException e) {
throw new FacesException(e);
}
}
方法 getCompleteURL 被调用并返回正确的 URL,但 JSF 没有重定向到新的 URL。
JBoss 正在接收 HTTP 连接。管理 HTTPS 的是 Apache,它重定向到 JBoss:
<VirtualHost *:443>
...
ProxyPass / http://server:8080/
ProxyPassReverse / http://server:8080/
</VirtualHost>
我更愿意在不使用 getCompleteURL 的情况下解决此问题,但如果不可能,请帮助我使用其他方法。
【问题讨论】: