I am reading four columns form DB and preparing them to display by using jsp and spring form tags. I am able read them using hibernate and added the entire list to model. Now, how can i read them and display in dropdowns. My Pojo looks like this
class bean{
String name; //represents a column in DB
Sting id
String some;
String data;
//getters and setter
and in my model i am returning as a list
List<bean> invoiceData = servicedao();
model.addAttribute("listdb", invoiceData);
How should i display now in jsp all coloumn values like
invoiceData.getsome();//using getters reading cell value
Can any one help me on this problem? Thanks in advance.
Use JSTL to loop through and display data.
<c:forEach items="${listdb}" var="invoice">
name : ${invoice.name}
.....
</c:forEach>
You can iterate List<bean>
through java or JSTL
.
For JSTL
you need to add <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
taglib in JSP
head.
now iterate values using JSTL foreach
<c:forEach items="${listdb}" var="bean">
//var bean is used to get bean value on every iteration
name = ${bean.name}
some = ${bean.some}
data = ${bean.data}
</c:forEach>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.