JSTL对List嵌套List的ForEach求和

A Example:
<c:set var="total" value="${0}"/>
<c:forEach var="tList" items="${bPositions}">
  <c:set var="total" value="${total + (tList.amount*tList.price)}"/>
</c:forEach>
<c:out value="${total}"/>






detailInfoList里放的是SchoolClassDetailInfo
SchoolClassDetailInfo.java:
public class SchoolClassDetailInfo {
	private String gradeName;
	private List<String> classList;
	private String testStr="aa,bb,cc";
}

怎样求得detailInfoList中的班级总数(即该List中几个classList的长度总和)?JSTL求法如下:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 

<c:set var="total" value="${0}"/>
<c:forEach items="${detailInfoList}" var="detailInfo">
<c:set var="total" value="${total + fn:length(detailInfo.classList)}"/>
</c:forEach>
<c:out value="${total}"/>

你可能感兴趣的:(java,html,c,jsp,sun)