저는 jsp를 사용하여 jsp를 배우려는 초보자입니다. j_security_check를 사용하여 로그인 페이지를 만듭니다.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>
그러나 한 번 올바른 자격 증명을 입력 한 후, 그냥 모드 "로그인"에 남아, 내가 서버를 다시 시작할 때 다시 로그인하라고 메시지를 표시하지 않습니다.
하지만 (뭔가 FacesContext
에 대한 잘못된로, 마지막 하나를 제외하고) 나는
HttpSession session=request.getSession(); session.invalidate();
뿐만 아니라 How to properly logout of a Java EE 6 Web Application after logging in에
<% request.getSession().invalidate(); request.getSession(false); %>
또한 답변을 사용하여 시도했다 모두 작동하지 않는 것 같습니다. 그래서 내 질문은 어떻게 로그 아웃합니까? 내 구조에 문제가 있습니까? 모든 도움을 주시면 감사하겠습니다.