如何从GWT应用程序正确注销以避免浏览器加载缓存数据?

时间:2012-06-15 14:37:04

标签: javascript gwt

我有一个基于GWT构建的企业Web应用程序,可以通过外部身份验证模块进行访问。我的问题是:

  • 我使用登录页面登录应用程序。
  • 我被指示(使用反向代理规则)到我加载GWT应用程序的Tomcat服务器。
  • 使用该应用。
  • 我退出了应用程序。
  • 当我尝试重新登录时,我没有登录页面。

如果我再次输入登录页面的URL,浏览器会开始加载我没有登录页面的缓存数据。我必须点击重新加载才能进入登录页面。怎么会这样? F5有什么特别之处告诉浏览器不要使用缓存?

我知道我的任何请求都没有遇到代理,这意味着所有浏览器都在加载缓存元素。

有人有任何线索吗?

2 个答案:

答案 0 :(得分:1)

我没有清楚地理解你的问题,但我认为我有类似的问题。我希望它对你有所帮助。

我有我的GwtPage.html和所有GWT内容都在web.xml中保护。

当我第一次访问http://example.com/GwtPage.html时,容器的安全性将我发送到login.jsp。登录完成后,我被发送到GwtPage.html,所以一切都很好。

但是第二次GwtPage.html被浏览器缓存了,容器没有发给我login.jsp。所以我做了以下事情: 我只用一行创建了index.jsp:

<%
    response.sendRedirect("GwtPage.html");
%>

并将其添加到安全资源列表中。

浏览器不会缓存它,因此容器总是向我发送登录页面。

第二个好处是GwtPage.html仍然被浏览器缓存,非常好,因为它很重。

我的web.xml:

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<!-- Security -->
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Index Page</web-resource-name>
        <url-pattern>/index.jsp</url-pattern>
    </web-resource-collection>    
    <web-resource-collection>
        <web-resource-name>Main Page</web-resource-name>
        <url-pattern>/GwtPage.html</url-pattern>
    </web-resource-collection>
    <web-resource-collection>
        <web-resource-name>Gwt entrails</web-resource-name>
        <url-pattern>/Gwt/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>VIEWER</role-name>
    </auth-constraint>
</security-constraint>

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>myrealm</realm-name>
    <form-login-config>
        <form-login-page>/LoginForm.jsp</form-login-page>
        <form-error-page>/LoginError.jsp</form-error-page>
    </form-login-config>
</login-config>

答案 1 :(得分:1)

我遇到了同样的问题。 注销GWT模块后没有启动。

<a id="logout" href="${pageContext.request.contextPath}/j_spring_security_logout">Logout</a>

解决方案非常简单,应该在打开登录页面之前自动刷新

spring-security.xml

中的

<security:logout logout-success-url="/logout.html"/>

<强> logout.html

<head lang="en">
  <meta http-equiv="REFRESH" content="0;  url=login.html">
</head>
相关问题