我的应用程序位于测试服务器上,仅通过 https 执行。当我在不重定向的情况下导航时,它工作得很好:
Example:
<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 的情况下解决这个问题,但如果不可能,请帮助我使用其他方法。