Skip to content

Instantly share code, notes, and snippets.

@bytestree bytestree/login.jsp
Last active May 6, 2016

Embed
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"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>Spring Security</title>
</head>
<body>
<div>
<form action="login" method="post">
<fieldset>
<legend>Please Login</legend>
<c:if test="${param.error != null}">
<div>
<p>Authentication Failed : ${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}</p>
</div>
</c:if>
<c:if test="${param.logout != null}">
<div>
<p>You have been logged out successfully.</p>
</div>
</c:if>
<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>
<div>
<button type="submit">Log in</button>
</div>
</fieldset>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
</div>
</body>
</html>
@bytestree

This comment has been minimized.

Copy link
Owner Author

bytestree commented May 6, 2016

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
You can’t perform that action at this time.