使用Spring Security,如何在成功登录后留在登录页面?

时间:2014-04-08 11:33:16

标签: spring spring-security

使用Spring Security,如何在成功登录后留在登录页面上?

我的Spring配置文件的这一部分:

<http auto-config="true" use-expressions="true">
    <form-login authentication-failure-url="/index.jsp?failed=true" default-target-url="/index.jsp" />
    <logout logout-success-url="/index.jsp" />
</http>

我有一个jsp片段文件/WEB-INF/jsp/subhead.jspf

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

<c:url var="postLoginUrl" value="j_spring_security_check" />
<c:url var="logoutUrl"    value="j_spring_security_logout"/>

<c:if test="${param.failed == true}">Login Failed...</c:if>

<security:authorize access="isAnonymous()">
    <form action="${postLoginUrl}" method="post">
        Username: <input type="text" name="j_username"/>
        Password: <input type="password" name="j_password" />
        <input type="submit" value="Log in"/>
    </form>
</security:authorize>

<security:authorize access="isAuthenticated()">
    Hi, <security:authentication property="principal.username"/> <a href="${logoutUrl}">Log out</a>
</security:authorize>

我有一个页面说test.jsp

<html>      
  <body>
    <%@ include file="/WEB-INF/jsp/subhead.jspf" %>
  </body>
</html>

我该如何制作

  • 登录成功
  • 登录失败
  • 注销

所有重定向都返回登录页面(test.jsp)?

目前,他们都将重定向到/index.jsp

0 个答案:

没有答案