[英]I want to display one by one value in JSP from spring controller
In my spring controller I have while loop which get new values everytime,I want to send new values to JSP from model attribute,this is used for line chart In my spring controller I have while loop which get new values everytime,I want to send new values to JSP from model attribute,this is used for line chart
Quoting your comment: I have while loop which extract text from many images,this while loop in inside separate thread, I'm only getting the last value after while loop finishes,model.attribute("send",newvalues) is inside while loop.
引用您的评论: I have while loop which extract text from many images,this while loop in inside separate thread, I'm only getting the last value after while loop finishes,model.attribute("send",newvalues) is inside while loop.
That means your values are immediately being replaced by the new ones inside the loop as they hold the same variable name.这意味着您的值将立即被循环内的新值替换,因为它们具有相同的变量名。 So, either you need to store them in different variable or follow the below steps:因此,您需要将它们存储在不同的变量中或按照以下步骤操作:
This should work.这应该有效。 Let me know if you face any difficulties doing this.如果您在执行此操作时遇到任何困难,请告诉我。
I hope this will help you for achieve your goals.我希望这将有助于您实现目标。
To use the JSTL core tags in JSP pages by adding the following taglib directive:要在 JSP 页面中使用 JSTL 核心标签,请添加以下 taglib 指令:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
And to iterate list values, JSTL core have <c:forEach/> tag.为了迭代列表值,JSTL 核心有 <c:forEach/> 标签。 It will display the list values one by one.它将一一显示列表值。
<c:forEach var="emp" items="${empList}">
...
</c:forEach>
Dependency Required需要依赖
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
reference: https://www.websparrow.org/spring/how-to-iterate-list-on-jsp-in-spring-mvc参考: https://www.websparrow.org/spring/how-to-iterate-list-on-jsp-in-spring-mvc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.