dimanche 19 avril 2015

Spring Security 4, not redrict after login

Here is my Login page: loginpage.jsp:



<html>
<head>
<title>Login Page</title>
</head>
<body onload='document.f.username.focus();'>
<h3>Login with Username and Password</h3>
<form name='f'action='${pageContext.request.contextPath}/loginpage'method='POST'>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<table>
<tr>
<td>User:</td>
<td><input type='text' name='username' value=''></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password' /></td>
</tr>
<tr>
<td colspan='2'><input name="submit" type="submit"
value="Login" /></td>
</tr>
</table>
</form>
</body>
</html>


here is my config file:



<security:http use-expressions="true">
<security:intercept-url pattern="/createroom" access="isAuthenticated()" />
<security:intercept-url pattern="/docreate" access="isAuthenticated()" />
<security:intercept-url pattern="/" access="permitAll" />
<security:intercept-url pattern="/loginpage" access="permitAll" />
<security:intercept-url pattern="/room" access="permitAll" />
<security:intercept-url pattern="/**" access="denyAll" />
<security:form-login login-page="/loginpage" />
</security:http>


And here is my controller: // this is my login controller import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class LoginController {



@RequestMapping("/loginpage")
public String showLogin(HttpServletRequest httpServletRequest){
// go to login page
return "loginpage";
}
}

Aucun commentaire:

Enregistrer un commentaire