當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
[SpringSecurity]web权限方案_用户认证_自定义用户登录页面
生活随笔
收集整理的這篇文章主要介紹了
[SpringSecurity]web权限方案_用户认证_自定义用户登录页面
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在配置類中實現相關的配置
@Overrideprotected void configure(HttpSecurity http) throws Exception {http.formLogin() //自定義自己編寫的登陸頁面.loginPage("/login.html") //登陸頁面設置.loginProcessingUrl("/user/login") //登陸訪問路徑.defaultSuccessUrl("/test/index").permitAll() //登陸成功之后,跳轉路徑.and().authorizeRequests().antMatchers("/","/test/hello","/user/login").permitAll() //設置哪些路徑可以直接訪問,不需要認證.anyRequest().authenticated().and().csrf().disable(); //關閉csrf防護}創建出相關頁面,controller
- login.html
特別注意,表單那兩個value必須是username和password,閱讀UsernamePasswordAuthenticationFilter的源碼就知道為什么了!
- controller
測試
總結
以上是生活随笔為你收集整理的[SpringSecurity]web权限方案_用户认证_自定义用户登录页面的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [SpringSecurity]web权
- 下一篇: [SpringSecurity]web权