2015-08-22 51 views
0

嗨,我正在开发springboot项目,并将thymeleaf.extras.springsecurity4添加到了我的项目中。实际上,它已经工作了很长一段时间,但知道这是不是working.not工作部分是秒:授权=“hasRole(‘正常’)”的thymeleaf.extras.springsecurity4秒:授权不起作用

   <p>Kontrol Paneli</p> 
       <span sec:authentication="name">Bob</span> 
       Roles: <span sec:authentication="principal.authorities">[ROLE_USER, ROLE_ADMIN]</span> | 
       <p sec:authorize="!hasRole('NORMAL')">I am here</p> 
       <p sec:authorize="!hasRole('ADMIN')">I am here</p> 
      </a></li> 

And result is enter image description here

显示为你看到秒代码:授权不关心用户具有哪个角色。

回答

0

其实我找到了解决办法,原因是springboot版本。我没有使用发布版本,因此我的项目无法按我的期望工作。为了防止你的项目错误,你必须使用发布版本,特别是在生产中。

谢谢