【发布时间】:2014-12-25 03:24:52
【问题描述】:
有没有办法转换一个jsp代码的形式
<security:authorize access="hasRole('ROLE_USER')">You're an user</security:authorize>
<security:authorize access="hasRole('ROLE_ADMIN')">You're an admin</security:authorize>
<security:authorize access="hasRole('ROLE_SADMIN')">You're a superadmin</security:authorize>
到另一种形式,类似于以下(不起作用)?
<c:choose>
<c:when test="hasRole('ROLE_USER')">
You're an user
</c:when>
<c:when test="hasRole('ROLE_ADMIN')">
You're an admin
</c:when>
<c:when test="hasRole('ROLE_SADMIN')">
You're a superadmin
</c:when>
<c:otherwise>
You have no relevant role
</c:otherwise>
</c:choose>
更准确地说,有没有办法用 JSTL 标签替换这个 Spring Security taglib 功能?
【问题讨论】:
-
您可以通过创建与 Spring 标签执行相同操作的自定义标签来做到这一点。但你只会重新发明轮子。
-
当我没记错的时候,重新发明轮子是我一年前找到的解决这个问题的唯一方法。
标签: java spring jsp spring-security taglib