J_security_check会话没有结束
问题描述:
我是一个尝试通过j_security_check的帮助创建登录页面来学习jsp的初学者。J_security_check会话没有结束
在以下web.xml
的代码中,您可以看到受保护文件夹中的所有内容都需要您登录才能访问。
<welcome-file-list>
<welcome-file>protected/home.jsp</welcome-file>
</welcome-file-list>
<security-constraint>
<display-name>Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/protected/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name> manager </role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Example Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/protected/home.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description> An administrator </description>
<role-name> manager </role-name>
</security-role>
一旦进入正确的凭证后,但是,它只是停留在“登录”模式,当我重新启动服务器时,它不提示我再次登录。我一直在使用
HttpSession session=request.getSession(); session.invalidate();
以及
<% request.getSession().invalidate(); request.getSession(false); %>
,并在How to properly logout of a Java EE 6 Web Application after logging in答案试过(除了最后一个,因为一些关于FacesContext
出了错)
,但他们都似乎没有工作。所以我的问题是如何注销?我的结构中有没有问题?所有的帮助表示赞赏。
答
登录页面简单地更改为实际登录页面:
<form-login-config> <form-login-page>/login.jsp</form-login-page> <form-error-page>/error.jsp</form-error-page> </form-login-config>