如何在web.xml中为ViewExpiredException配置错误页面?

时间:2016-04-10 13:30:47

标签: jsf-2

这在web.xml中配置为 -

    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/ch9/ch9_5/expired.xhtml</location>
    </error-page>

Eclipse中的结构是 -

enter image description here

index.xhtml page -

    <h:body>                   
        Please, force view expiration!
        <h:form>
            <h:commandButton value="Logout!" action="#{logoutBean.logoutAction()}"/>
        </h:form>
    </h:body>

LogoutBean.java -

@ManagedBean
@javax.faces.bean.RequestScoped
public class LogoutBean {

    public String logoutAction() throws IOException {

        ExternalContext externalContext = 
                            FacesContext.getCurrentInstance().getExternalContext();
        externalContext.invalidateSession();

        return "byebye.xhtml?faces-redirect=true;";
    }
}

byebye.xhtml -

    <h:body>
        Bye, Bye session! You are logout! Press browser back button ...
    </h:body>

expired.xhtml -

    <h:body>
        Your session expired ...
        <h:link value="Go to Login Page ..." outcome="index.xhtml" />         
    </h:body>

视图过期后,这会在Google Chrome中显示。

enter image description here

1)第一个问题是只显示硬编码文本,而不是链接

  

您的会话已过期...(index.xhtml没有链接)

2)如何在浏览器窗口中反映错误页面网址?

3)第三,在IE 11.0.9600中,错误页面根本没有出现。可能是什么原因?如何保持这两种浏览器的一致性?

0 个答案:

没有答案