摆脱使用h:button时URL中的jsessionid=xxx路径参数



我在Tomcat7和JSF 2.1中使用OmniFaces FullAjaxExceptionHandler来处理ViewExpiredException。我已经设置了与OmniFaces展示相同的错误页面。在这里查找错误页面,在这里查找模板。

它运行良好。当会话过期时,我将进入expired.xhtml错误页面。然而,当我点击错误页面中的以下链接时,

 <p><a href="#{requestScope['javax.servlet.error.request_uri']}">Back to initial page.</a></p>

然后我得到以下异常:

com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean 

这不是什么大问题。我需要一个按钮,指向用户的主页无论如何。所以我用下面的按钮代替了它:

<h:button value="Home" outcome="logout" />

连同这个导航案例:

<navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
        <from-outcome>logout</from-outcome>
        <to-view-id>/stdPortal/index.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>

导航将我带到了正确的页面,但会话ID显示在URL:中

https://localhost/stdPortal/index.xhtml;jsessionid=B68784B4ED8882A6575A2EE4012AF1B5

我不想要这个。我该如何摆脱它?我希望URL像:

https://localhost/stdPortal/index.xhtml

您可以通过在web.xml:中添加以下内容来消除URL中的jsessionid路径片段

<session-config>
    <tracking-mode>COOKIE</tracking-mode>
</session-config>

它基本上禁止URL重写。

最新更新