在Websphere中对AngularJS使用基于表单的身份验证时的奇怪行为
我正在使用基于表单的身份验证处理AngularJS项目,有时会出现意外行为 我无法追踪 运行在WebSphere8.0.0.10上的应用程序,会话管理由cookies完成 所需的工作流程如下:在Websphere中对AngularJS使用基于表单的身份验证时的奇怪行为,angularjs,jakarta-ee,caching,websphere,Angularjs,Jakarta Ee,Caching,Websphere,我正在使用基于表单的身份验证处理AngularJS项目,有时会出现意外行为 我无法追踪 运行在WebSphere8.0.0.10上的应用程序,会话管理由cookies完成 所需的工作流程如下: 打开应用程序,尝试获取受限资源 Websphere正在将应用程序重定向到login.html,存在web.xml安全约束: <security-constraint> <display-name>userConstraint</display-name&
- 打开应用程序,尝试获取受限资源
- Websphere正在将应用程序重定向到login.html,存在web.xml安全约束:
它转到<security-constraint> <display-name>userConstraint</display-name> <web-resource-collection> <web-resource-name>userResource</web-resource-name> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <description>user</description> <role-name>user</role-name> </auth-constraint> </security-constraint> <security-constraint> <web-resource-collection> <web-resource-name>Allowed resources</web-resource-name> <url-pattern>/js/*</url-pattern> <url-pattern>/css/*</url-pattern> <url-pattern>/myStyle/*</url-pattern> </web-resource-collection> </security-constraint> <login-config> <auth-method>FORM</auth-method> <realm-name>Example Form-Based Authentication Area</realm-name> <form-login-config> <form-login-page>/login.html</form-login-page> <form-error-page>/login.html?retry=true</form-error-page> </form-login-config> </login-config> <security-role> <role-name>user</role-name> </security-role>
,但应用程序不工作,引发各种异常,无法启动该模块或该模块 即使我手动删除了cookies,或者即使我在Chrome中打开了应用程序 当会话到期时,不登录窗口,Websphere应将其重定向到login.html。 只有当我再次刷新它时,它才会转到login.html 如果我理解正确,浏览器和应用程序的某些模块会部分缓存它 从缓存加载,甚至更多,当我加载应用程序时,开发人员控制台打开并禁用缓存 它可以完美地工作,但当控制台关闭时,它就不工作了 我试图通过将以下代码添加到我的“/page”
中来禁用缓存,但没有帮助:index.html
<meta http-equiv="cache-control" content="max-age=0" /> <meta http-equiv="cache-control" content="no-cache" /> <meta http-equiv="expires" content="0" /> <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" /> <meta http-equiv="pragma" content="no-cache" />
提前谢谢。问题已解决。我在@WebFilter中使用了以下几行:HttpServletResponse response = (HttpServletResponse) res; response.addHeader("Pragma", "no-cache"); response.addHeader("Cache-Control", "no-cache"); response.addHeader("Cache-Control", "no-store"); response.addHeader("Cache-Control", "must-revalidate"); response.addHeader("Expires", "Tue, 01 Jan 1980 1:00:00 GMT");
HttpServletResponse response = (HttpServletResponse) res; response.addHeader("Pragma", "no-cache"); response.addHeader("Cache-Control", "no-cache"); response.addHeader("Cache-Control", "no-store"); response.addHeader("Cache-Control", "must-revalidate"); response.addHeader("Expires", "Tue, 01 Jan 1980 1:00:00 GMT");