jak*_*kob 0 freemarker spring-security
我正在研究一个项目,我们使用freemarker作为模板语言.我没有使用defualt登录表单,而是创建了一个自定义控制器和一个与该控制器一起使用的自定义freemarker视图
码:
@Controller
public class LoginController {
private static finaal String LOGIN = "components/security/login";
@RequestMapping("/security/login")
public String login(){
return LOGIN;
}
}
Run Code Online (Sandbox Code Playgroud)
我的freemarker模板:
HTML代码:
<form action="${rc.contextPath}/j_spring_security_check" method="post">
<label for="username">Username</label><input type="text" id="username" name="j_username"><br/>
<label for="password">Password</label><input type="text" id="password" name="j_password"><br/>
<input type="submit" value="Login!">
</form>
Run Code Online (Sandbox Code Playgroud)
我的applicationContext-security.xml
<http>
<logout/>
<intercept-url pattern="/*" access="ROLE_ADMIN, ROLE_GUEST"/>
<intercept-url pattern="/security/login" filters="none"/>
<form-login login-page="/security/login" />
</http>
Run Code Online (Sandbox Code Playgroud)
登录就像一个魅力但是,当用户输入错误的用户名或密码时,没有显示错误消息,我无法弄清楚如何做到这一点.你能帮我解决吗?
那些想知道我是怎么做的人的代码:
<#if Session.SPRING_SECURITY_LAST_EXCEPTION?? && Session.SPRING_SECURITY_LAST_EXCEPTION.message?has_content>
<@spring.message "login.bad.credentials"/>
</#if>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5069 次 |
| 最近记录: |