我是弹簧安全的初学者。我想尝试使用 login.jsp 进行身份验证。显示登录页面,但是当我进行身份验证时,它不会转到默认目标 URL。这是我的代码:spring-security-context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<security:http auto-config="true" use-expressions="true">
<security:intercept-url pattern="/login.jsp*" access="permitAll"/>
<security:intercept-url pattern="/Home.jsp*" access="hasRole('ROLE_FORMATEUR')" />
<security:intercept-url pattern="/**" access="hasRole('ROLE_FORMATEUR')"/>
<security:form-login login-page='/login.jsp'
default-target-url='/Home.jsp'/>
</security:http>
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider>
<security:user-service>
<security:user name="xxx" password="123" authorities="ROLE_FORMATEUR,ROLE_ADMIN" />
<security:user name="yyy" password="456" authorities="ROLE_FORMATEUR" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
登录.jsp
<body>
<form method="post" action="j_spring_security_check">
<table>
<tr>
<td> Login: </td>
<td> <input type="text" name="j_username"> </td>
</tr>
<tr>
<td> Mot de passe: </td>
<td> <input type="password" name="j_passxord"> </td>
</tr>
<tr>
<td colspan="2"> <input type="submit" value="Valider">
<input type="reset" value="Annuler"> </td>
</tr>
</table>
</form>
</body>