牛骨文教育服务平台(让学习变的简单)
博文笔记

服务器返回的list,map等类型,在JSP中取长度、取值的方法

创建时间:2015-11-23 投稿人: 浏览次数:2045
首先,取长度,用的是 EL函数 ${fn:length(list)}。
需要添加对JSTL的支持,jstl.jar,standard.jar,大部分的tomcat的lib下是不带这两个的,而是在example下,需拷贝到项目的lib下。
<%@ taglib <span style="font-family: Arial, Helvetica, sans-serif;">prefix</span><span style="font-family: Arial, Helvetica, sans-serif;">="c" </span><span style="font-family: Arial, Helvetica, sans-serif;">uri="http://java.sun.com/jsp/jstl/core"%> </span>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
list的长度是:${fn:length(list)}
</pre><pre id="best-content-942916481" class="best-text mb-10" name="code" style="white-space: pre-wrap; word-wrap: break-word; color: rgb(51, 51, 51); font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">取值方法一:
${result[0].id } ${result[0].name } ${result[1].id } ${result[1].name }

取值方法二:

<c:forEach items="${result}" var="Item">
               <tr>
                  <td>${Item.id}</td>
                  <td>${Item.name}</td>
                  <td>${Item.pwd}</td>
                  <td>${Item.gender}</td>
                  <td>${Item.age}</td>
               </tr>
</c:forEach>



            
                
				
			
		
        	
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。