Spring Security重命名登录表单标签名称

时间:2011-05-29 22:46:13

标签: forms spring-security

我是Spring Security登录表单,我们有以下表格

<form name='f' action='/j_spring_security_check' method='POST'> 
 <table> 
    <tr><td>User:</td><td><input type='text' name='j_username' value=''></td></tr> 
    <tr><td>Password:</td><td><input type='password' name='j_password'/></td></tr> 
    <tr><td colspan='2'><input name="submit" type="submit"/></td></tr> 
    <tr><td colspan='2'><input name="reset" type="reset"/></td></tr> 
  </table> 
</form>

我知道如何在此表单上修改操作属性(使用login-processing-url="/login") 我的问题是如何更改j_username&amp; j_password标记名称,是用户名和密码吗?

1 个答案:

答案 0 :(得分:10)

您的请求还有另一种方式:
Spring - Security : how are login username and password bound to the authentication-provider?
Spring Security 3- How to customize username/password parameters?

但最好的方法是更新Spring Security 3.1.0(最新版本为RC2,GA可能会在几个月后发布),form-login中的new configuration

<beans:beans>
  <http>
    <form-login username-parameter="username" password-parameter="password" />
  </http>
</beans:beans>