是否可以将变量名传递给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>