Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc 退出后Thymeleaf hasAuthority()不正确_Spring Mvc_Spring Security_Thymeleaf - Fatal编程技术网

Spring mvc 退出后Thymeleaf hasAuthority()不正确

Spring mvc 退出后Thymeleaf hasAuthority()不正确,spring-mvc,spring-security,thymeleaf,Spring Mvc,Spring Security,Thymeleaf,我对Theymleaf的安全实现有点争执 我有以下spring安全配置: protectedvoid配置(HttpSecurity http)引发异常{ http.csrf().disable() .授权请求() .antMatchers(“/login*”).permitAll() .antMatchers(“/admin/*”).hasAuthority(“admin”)) .antMatchers(“/”).permitAll() .anyRequest().authenticated()

我对Theymleaf的安全实现有点争执

我有以下spring安全配置:

protectedvoid配置(HttpSecurity http)引发异常{
http.csrf().disable()
.授权请求()
.antMatchers(“/login*”).permitAll()
.antMatchers(“/admin/*”).hasAuthority(“admin”))
.antMatchers(“/”).permitAll()
.anyRequest().authenticated()
.及()
.formLogin()
// ...
.及()
.logout()
.logoutUrl(“/logout”)
.logoutSuccessUrl(“/home”)
.使会话无效(真);
}
在我的HTML中,我有一些简单的设置:

<div sec:authorize="hasAuthority('ADMIN')">You're cool bro!</div>

您试图浏览的页面URL是什么?又是什么样的重启呢?这是重新加载应用程序(由Spring boot devtools管理)吗?稍微编辑一下这个问题;我只是重新加载基本url(主页“/”)。当我完全停止并启动服务器时,就会发生这种情况;使用devtools重新加载的行为与预期的一样看起来这不是Thymeleaf特有的。您是否正在使用保存身份验证信息的共享会话。不,只是基本的spring安全性打开检查器,查看请求是否已缓存。此外,这与即使不是缓存问题,也应该是spring安全性,而不是thymeleaf。thymeleaf只是向您展示了问题,它不可能是问题。