如何使用spring mvc将数据从控制器显示到jsp? [英] how to display data from controller to jsp using spring mvc?

查看:137
本文介绍了如何使用spring mvc将数据从控制器显示到jsp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我无法在春季显示控制器到jsp页面的数据,刚到春天,这是我的控制器

 列表与LT; DocDto> list = DocService.getDocs(); 
DocDto docList = new DocDto();
docList.setdocType(doc_type);
docList.setdocSubType(doc_subtype);
jobList.setTransactionId(transaction_id);
model.addAttribute(docList,docList);

这是我的jsp表格

 < c:forEach var =oitems =$ {list}> 
< tr>
< td>
< c:out value =$ {o.doc_type}/>< / td>
< td>< c:out value =$ {o.doc_subtype}/>< / td>
< / td>
< / tr>

这不会在我的jsp中显示任何数据,只是简单地显示它的空白表。任何帮助,将不胜感激。

解决方案

代替$ {list}在每个循环中使用$ {docList}。
如果没有成功,请按照以下步骤操作:

检查您是否在jsp中包含了适当的jstl库

 <%@ taglib uri =http://java.sun.com/jsp/jstl/coreprefix =c%> 

并为jstl库使用适当的jar。



检查DocDto是否有doc_type,doc_subtype变量是否拼写正确。


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.

解决方案

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.

这篇关于如何使用spring mvc将数据从控制器显示到jsp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆