如何在Spring Security中评估变量名hasAuthority()

时间:2019-11-11 16:42:32

标签: spring-boot jsp spring-security

是否可以将变量名传递给hasAuthority或hasAnyAuthority JSP标记?

我的JSP代码:

<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<% String customPermission = "PERM_" + myObj.getId(); %>

 <script>
     console.log('customPermission', '<%= customPermission %>');   // PERM_1234-56-7890
     console.log('customPermission', 'PERM_1234-56-7890');         // PERM_1234-56-7890
 </script>

 <sec:authorize access="hasAuthority('<%= customPermission %>')">
     <p>I'm never seen</p>
 </sec:authorize>


 <sec:authorize access="hasAuthority('PERM_1234-56-7890')">
     <p>Hello World</p>
 </sec:authorize>

0 个答案:

没有答案