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
How to iterate through a list in JSP using Spring framework
提问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>