Reputation: 429
Hi I am unable to display data from controller to jsp page in spring, am new to spring, this is my controller
List<DocDto> list =DocService.getDocs();
DocDto docList = new DocDto();
docList.setdocType(doc_type);
docList.setdocSubType(doc_subtype);
jobList.setTransactionId(transaction_id);
model.addAttribute("docList", docList);
This is my jsp table
<c:forEach var="o" items="${list}">
<tr>
<td>
<c:out value="${o.doc_type}" /></td>
<td><c:out value="${o.doc_subtype}" /></td>
</td>
</tr>
This is not displaying any data in my jsp, just simply blank table it is displaying. Any help would be appreciated.
Upvotes: 0
Views: 7063
Reputation: 1
In your case you have bind model.addAttribute("docList", docList); and you are trying to iterate by list you can use this model.addAttribute("list ", docList); then iterate .Hope it will work
Upvotes: 0
Reputation: 971
Instead of ${list} use ${docList} in for each loop. If it did not works then follow following steps :
Check you included proper jstl library in jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
and using proper jar for jstl library.
Check DocDto for doc_type,doc_subtype variables properly spelled or not.
Upvotes: 3
Reputation: 13821
You're calling your model attribute docList
, but you're trying to reference it as list
. Try
<c:forEach var="o" items="${docList}">
instead
Upvotes: 1