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

Qua*_*ynh 1 jstl spring-mvc spring-security

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

<sec:authentication property="authorities"/>
Run Code Online (Sandbox Code Playgroud)

所以我这样做:

<c:forEach var="auth" items="${'<sec:authentication property="authorities"/>'}" >
   <h3> Each- <c:out value="${auth.authority }"></c:out> </h3><br />
</c:forEach>
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

有帮助吗?

Xae*_*ess 6

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

<sec:authentication property="authorities" var="authorities" />
<c:forEach items="${authorities}" var="auth">
   <h3>Each- ${auth.authority}</h3>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)