DemoController:1
2
3
4
5
6
7
8
public class DemoController {
// This is the index of application
"/") (
public String showHome() {
return "home";
}
}
LoginController:1
2
3
4
5
6
7
8
9
public class LoginController {
// Due to the DemoSecurityConfig,
// before we accessing the index page, we have to login
"/showMyLoginPage") (
public String showMyLoginPage() {
return "fancy-login";
}
}
login.jsp:1
2
3
4
5<c:if test="${param.error != null}">
<div>
Invalid username and password.
</div>
</c:if>
In Spring Security system, if the log in step fails, there will be a param error
in the link, like:http://localhost:8080/showMyLoginPage?error
. So jstl can be used to check if the log in fails and show different pages.