spring security设置自定义登录loginProcessingUrl不生效的问题
spring security设置自定义登录loginProcessingUrl不生效的问题
·
只有security配置类、前端action请求页面、controller方法都一一对应,自定义的登录界面才可以成功。即使这样,登录时在controller打断点也不会进入,配置了个寂寞。但是,如果没有任何一个,那么自定义登录界面就不会成功。spring形式主义呀。验证还是交给spring security内部的验证方法。
//java配置类
@Override
public void configure(HttpSecurity http) throws Exception{
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login.html")
.usernameParameter("xx")
.passwordParameter("oo")
.loginProcessingUrl("/login")
.defaultSuccessUrl("/test").permitAll()
//前端thymleaf页面
<form action="/login" method="post">
<input name="xx">username</input>
<input name="oo">password</input>
<input th:name="${_csrf.parameterName}" th:value="${_csrf.token}" hidden>
<button type="submit">提交</button>
</form>
//controller控制器
@RequestMapping("/login")
public String loginWeb(){
System.out.println("路过");
return "成功";
}
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)