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
修改的 url 与form-login
的login-processing-url
属性中定义的 url 匹配Spring Security 配置中的元素. - 必须在 Spring Security 配置中
form-login
元素的login-page
属性中指定自定义登录表单的位置.
- 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.
登录.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屋!
查看全文