Using Spring Security logout with Struts 2
In this section let us implement a logout scenario, where the logged-in user will be logged out of the application. The logout action will be handled by the Spring Security framework. We need to configure the struts.xml
file to handle the j_spring_security_logout
action.
Getting ready
- Create a dynamic web project in Eclipse
- Add the Struts 2 related JARs
- Add Spring Security-related JARs
- The
web.xml
,struts2.xml
, and JSP settings remain the same as the previous application
How to do it...
- Let's update the secure page,
hello.jsp
:<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@page import="java.security.Principal" %> <html> <body> Hello .You are seeing a secured Page now. <a href="<c:url value="/j_spring_security_logout" />" > Logout</a> </body> </html>
- Let's map the
j_spring_security_logout
with thestruts.xml
file:When...