Skip to content

Instantly share code, notes, and snippets.

Last active May 6, 2016 12:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Custom Login page for Spring Security 4 including CSRF token config
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@ taglib prefix="c" uri=""%>
<title>Spring Security</title>
<form action="login" method="post">
<legend>Please Login</legend>
<c:if test="${param.error != null}">
<p>Authentication Failed : ${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}</p>
<c:if test="${param.logout != null}">
<p>You have been logged out successfully.</p>
<label for="username">Username</label>
<input type="text" id="username" name="username" /> <br>
<label for="password">Password</label>
<input type="password" id="password" name="password" /> <br>
<button type="submit">Log in</button>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
Copy link

Refer Spring Security 4 with Hibernate for complete example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment