是有辦法的形式春季安全開關的情況下在JSTL標籤
<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>
的JSP代碼轉換爲另一種形式,類似於以下(不工作)?
<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標籤自定義標籤做到這一點。但你只會重新發明輪子。 – 2014-10-29 12:27:02
當我記得正確的時候,重新發明車輪,是我一年前爲這個問題找到的唯一解決方案。 – Ralph 2014-10-29 12:43:00