小编zeh*_*zeh的帖子

Spring 4.0 + Security 3.2 + j_spring_security_check的JavaConfiguration

  1. 创建登录页面

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="ISO-8859-1">
            <title>Test</title>
            <script src="static/js/jquery-1.10.2.min.js"></script>
            <script src="static/js/app-controller.js"></script>
        </head>
        <body>
            <div>Login</div>
            <form name="f" action="<c:url value="/j_spring_security_check"/>" method="POST">
                <label for="password">Username</label>&nbsp;<input type="text" id="j_username" name="j_username"><br/>
                <label for="password">Password</label>&nbsp;<input type="password" id="j_password" name="j_password"><br/>
                <input type="submit" value="Validate">&nbsp;<input name="reset" type="reset">
                <input type="hidden" id="${_csrf.parameterName}" name="${_csrf.parameterName}" value="${_csrf.token}"/>
            </form>
            <hr/>
            <c:if test="${param.error != null}">
                <div>
                    Failed to login.
                    <c:if test="${SPRING_SECURITY_LAST_EXCEPTION != null}">
                      Reason: <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}" />
                    </c:if>
                </div>
            </c:if>
            <hr/>
            <input type="button" value="Echo" id="echo" name="echo" onclick="AppController.echo();">
            <div id="echoContainer"></div>
    
        </body>
    </html>
    
    Run Code Online (Sandbox Code Playgroud)
  2. 这里声明一个WebSecurityConfigurer …

spring spring-mvc spring-security spring-java-config

10
推荐指数
1
解决办法
1万
查看次数