小编DHa*_*sen的帖子

JSF从HTTPS重定向到HTTP

我的应用程序在测试服务器上完全通过https执行.当我在没有重定向的情况下导航时,它完美地工作:

例:

<p:menuitem value="#{msg.customerScreen}" url="/restrict/customer.xhtml" />
<p:menuitem value="#{msg.productScreen}" url="/restrict/product.xhtml" />
Run Code Online (Sandbox Code Playgroud)

但是当我需要重定向到另一个页面时,它会重定向到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>
Run Code Online (Sandbox Code Playgroud)

作为一种解决方法,我尝试重建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);
    }
}
Run Code Online (Sandbox Code Playgroud)

正在调用方法getCompleteURL并返回URL correclty,但JSF不会重定向到新URL.

JBoss正在接收HTTP连接.谁管理HTTPS是Apache,重定向到JBoss:

<VirtualHost *:443>

    ...

    ProxyPass / http://server:8080/
    ProxyPassReverse / http://server:8080/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

我更愿意在不使用getCompleteURL的情况下解决此问题,但如果不可能,请帮助我解决其他问题.

https jsf

4
推荐指数
1
解决办法
3904
查看次数

标签 统计

https ×1

jsf ×1