如何使用Spring框架遍历JSP中的列表

Moh*_*aie 6 java spring jsp spring-mvc

所以,我有一个列表,我通过模型从Spring控制器传递给JSP.如何遍历JSP中的列表?

假设,该列表有几个我希望在JSP中显示的超链接.没有scriptlets怎么做?

小智 12

你可以使用jstl标签并显示列表

<c:forEach var="listVar" items="${listName}"> //add the model attribute of list in items
    <option value ="10"><c:out value="${listVar.attribute}"/></option>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)