如何使用jstl c:foreach迭代返回的spring安全标记

时间:2012-10-12 10:38:23

标签: spring-mvc spring-security jstl

在我使用spring security的应用程序中,我需要迭代

返回的权限
<sec:authentication property="authorities"/>

所以我这样做:

<c:forEach var="auth" items="${'<sec:authentication property="authorities"/>'}" >
   <h3> Each- <c:out value="${auth.authority }"></c:out> </h3><br />
</c:forEach>

但它不起作用。这是控制台中的错误:

SEVERE: Servlet.service() for servlet [appServlet] in context with path [/portal] threw exception [Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException: ServletException including path '/WEB-INF/views/layouts/standard.jsp'.] with root cause org.apache.jasper.JasperException: /WEB-INF/views/resman/about/about.jsp (line: 40, column: 85) equal symbol expected

任何帮助?

1 个答案:

答案 0 :(得分:6)

将权限分配给新变量,然后执行循环:

<sec:authentication property="authorities" var="authorities" />
<c:forEach items="${authorities}" var="auth">
   <h3>Each- ${auth.authority}</h3>
</c:forEach>