Spring Security登录页面 [英] Spring Security Login Page
本文介绍了Spring Security登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开发了一个使用Spring Security默认登录页面的应用程序。但是我想实现自己的登录页面。我将放一个login.html而不是一个jsp页面。我想用它来使用JQuery。我检查了许多例子,但无法实现。我是Spring和Spring Security的新手,我使用Spring Security 3.
我应该遵循哪些步骤?
I developed an application that uses Spring Security's default login page. However I want to implement my own login page. I will put a login.html instead of a jsp page. I want to use JQuery for it. I examined many examples but couldn't achieve. I am new to Spring and Spring Security, I use Spring Security 3. Any ideas which steps I should follow?
推荐答案
Spring Security中的自定义登录页面有四个要求:
There are four requirements for a custom login page in Spring Security:
- 有一个名为
的输入字段j_username
,其中包含用于身份验证凭据的名称。 - 有一个名为
j_password
的输入字段将包含用于身份验证凭据的密码。 - 这些值
POST
ed的网址与<中定义的网址匹配code> login-processing-url Spring Security配置中form-login
元素的属性。 - 必须在
form-login
登录页面属性中指定自定义登录表单的位置您的Spring Security配置中的>元素。
- There is an input field named
j_username
which will contain the name used for the authentication credentials. - There is an input field named
j_password
which will contain the password used for the authentication credentials. - The url to which these values are
POST
ed matches the url defined in thelogin-processing-url
attribute of theform-login
element in your Spring Security configuration. - The location of the custom login form must be specified in the
login-page
attribute of theform-login
element in your Spring Security configuration.
Login.html
<body>
<form action="/j_spring_security_check" method="POST">
<label for="username">User Name:</label>
<input id="username" name="j_username" type="text"/>
<label for="password">Password:</label>
<input id="password" name="j_password" type="password"/>
<input type="submit" value="Log In"/>
</form>
</body>
Spring安全配置文件
<http use-expressions="true">
<intercept-url pattern="/login*" access="isAnonymous()"/>
<intercept-url pattern="/**" access="isFullyAuthenticated()"/>
<form-login
login-page="/login.html"
login-processing-url="/j_spring_security_check.action"
authentication-failure-url="/login_error.html"
default-target-url="/home.html"
always-use-default-target="true"/>
</http>
这篇关于Spring Security登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文