我正在使用Tuckey URLRewriteFilter。在我的应用程序中,我有以下页面和按钮:
inside.xhtml
位于应用内容中:http://example.com/app/inside.xhtml outside.xhtml
不在应用的上下文中:http://example.com/outside.xhtml login.xhtml
login button
页面上的outside.xhtml
转到login.xhtml
页面。profile.xhtml
logout button
页面上的profile.xhtml
转到inside.xhtml
页面。在umlrewrite.xhtml
文件中,我有以下规则从inside.xhtml
重定向到outside.xhtml
:
<rule>
<note>
Requests to /app/inside.xhtml will be redirected to ./../../outside.html
</note>
<from>/app/inside.xhtml</from>
<to type="redirect">./../../outside.html</to>
</rule>
我的逻辑是,在用户登录login.xhtml
页面后,他将被重定向到profile.xhtml
页面。我期望发生的是以下流程:
outside.xhtml
。login button
转到login.xhtml
并登录。profile.xhtml
。logout button
转到inside.xhtml
。outside.xhtml
。然而,实际发生的是:
outside.xhtml
。login button
转到login.xhtml
并登录。outside.xhtml
。 login button
转到login.xhtml
并重新登录(该应用未记录我的登录信息)。 profile.xhtml
。logout button
转到inside.xhtml
。outside.xhtml
。如果我在步骤2
之后继续执行步骤7
,则会反复发生上述情况。
如果没有<rule>
,我会在成功登录时正确地重定向到profile.xhtml
页面。
如果你能就这个问题给我一些建议,我将非常感激。
更新
在我的应用中,为了跟踪logged in
状态,我有一个@SessionScoped
托管bean,其中包含一个记录状态的简单方法:
public void recordUserLoggedIn(HttpServletRequest request) {
HttpSession clientSession = request.getSession();
clientSession.setAttribute("isLogin", true);
}
答案 0 :(得分:0)
您没有指定跟踪“登录”状态的方式。您使用的是自定义Cookie吗?依赖于应用服务器的内置会话处理(可能也基于cookie)?
问题的最可能原因与您跟踪登录状态的方式有关,以及您在各个页面之间如何传递状态&amp;上下文。 (特别是在从登录状态转换为profile.xhtml时。)请记住,cookie可以基于路径。
调试问题:
如果您使用的是浏览器,请使用firebug / developer-tools并观看网络标签。特别要检查流程中每个步骤中设置的各种标题。
我认为通过在流程中观察HTTP标头,潜在的问题将变得明显。