Ben*_*ler 2 spring spring-security spring-boot
我有一个带有简单表单登录的Spring Boot应用程序。登录正常。
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login")
.permitAll();
Run Code Online (Sandbox Code Playgroud)
我还通过CookieLocaleResolver和LocaleChangeInterceptor进行了国际化。登录后也可以使用。
我的问题是:
用户在登录页面上时无法更改语言环境。
登录页面:https:// localhost / login
链接以更改语言环境:https:// localhost / login?locale = en
但是用户再次被重定向到https:// localhost / login,区域设置保持不变。
有没有办法在登录页面上允许参数?
谢谢你的帮助!
小智 5
遇到了相同的问题,并已解决以下问题:
http
.authorizeRequests()
.antMatchers("/login/**")//Basically I'm allowing parameters for login so locale can be added and read.
.permitAll()
.anyRequest()
.fullyAuthenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login")
.permitAll();
Run Code Online (Sandbox Code Playgroud)
我认为问题在于,当您更改语言环境时,将其作为参数发送,并且由于conf不允许使用/ login参数,因此它将刷新并显示登录页面以尝试对您进行身份验证。
| 归档时间: |
|
| 查看次数: |
921 次 |
| 最近记录: |