spring security心得
今天在做双因子登录的时候遇到一个问题,项目用的是springsecurity的框架.我在登录界面做的判断如果开启了双因子登录的话就跳转到手机号验证界面登录.
CodeFilter是登录方法
CodeFilterMobile是手机号登录的方法,当走到手机号登录的时候发现并不能登录上去,日志也显示登陆成功了.后来我就去查了一下关于springsecurity的资料发现他的登录方法只能是/j_spring_security_check也就是CodeFilter跳转所对应的地址
登录页面
<form%action="
p
a
g
e
C
o
n
t
e
x
t
.
r
e
q
u
e
s
t
.
c
o
n
t
e
x
t
P
a
t
h
/
j
s
p
r
i
n
g
s
e
c
u
r
i
t
y
c
h
e
c
k
"
m
e
t
h
o
d
=
"
p
o
s
t
"
>
用
户
:
<
i
n
p
u
t
t
y
p
e
=
"
t
e
x
t
"
n
a
m
e
=
"
j
u
s
e
r
n
a
m
e
"
v
a
l
u
e
=
"
{pageContext.request.contextPath}/j_spring_security_check" method="post"> 用户: <input type="text" name="j_username" value="
pageContext.request.contextPath/jspringsecuritycheck"method="post">用户:<inputtype="text"name="jusername"value="{SPRING_SECURITY_LAST_USERNAME}"/>
密码: <input%type=“password” name=“j_password”/>
<input%type=“checkbox” name="_spring_security_remember_me" />两周之内不必登陆
<input%type=“submit” value=“登陆”/>
页面中输入控件的name属性和form的action地址必须符合spring security的规定!也就是说登录必须走到/j_spring_security_check才可以.而且账号密码的参数名称也必须是j_username;j_password
参考资料如下(这个博主写的还是不叫全面的从前期搭建开始):
https://www.cnblogs.com/yl2755/archive/2012/04/19/2456823.html