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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19160772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 14:36:48  来源:igfitidea点击:

How to iterate through a list in JSP using Spring framework

javaspringjspspring-mvc

提问by Mohamed Taher Alrefaie

So, I have a list that I passed it through the model from my Spring controller to JSP. How do I iterate through the list inside the JSP?

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

Assume, the list has several hyperlinks that I would like to display in JSP. How to do this without scriptlets?

假设列表中有几个我想在 JSP 中显示的超链接。如何在没有脚本的情况下做到这一点?

采纳答案by Chirag Kathiriya

you can use jstl tag and display the list

您可以使用 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>