jsp 按照数据规则输出类似合并单元格类型的数据

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<body>
	<%
		List list = new ArrayList();
		String[] arr1 = new String[] { "a", "b", "c", "d", "e" };
		String[] arr2 = new String[] { "a", "b", "c", "d", "e" };
		String[] arr3 = new String[] { "a", "b", "c", "d", "e" };
		String[] arr4 = new String[] { "a", "b", "c", "d", "e" };
		list.add(arr1);
		list.add(arr2);
		list.add(arr3);
		list.add(arr4);
		
		List lista = new ArrayList();
		lista.add("税种");
		lista.add(list);
		
		List list1 = new ArrayList();
		String[] arr11 = new String[] { "a", "b", "c", "d", "e" };
		String[] arr22 = new String[] { "a", "b", "c", "d", "e" };
		String[] arr33 = new String[] { "a", "b", "c", "d", "e" };
		String[] arr44 = new String[] { "a", "b", "c", "d", "e" };
		String[] arr55 = new String[] { "a", "b", "c", "d", "e" };
		list1.add(arr11);
		list1.add(arr22);
		list1.add(arr33);
		list1.add(arr44);
		list1.add(arr55);
		
		List listb = new ArrayList();
		listb.add("税种");
		listb.add(list1);
		
		List listc = new ArrayList();
		listc.add(lista);
		listc.add(listb);
		
		request.setAttribute("listc", listc);
	%>
	<table border="1" bordercolor="red"  style="margin: 0;padding: 0">
	<tr>
	<td>税种</td>
	<td>金额</td>
	<td>金额</td>
	<td>金额</td>
	<td>金额</td>
	<td>金额</td>
	</tr>
		<c:forEach items="${listc}" var="subList1">
			<tr>
			<td rowspan="${fn:length(subList1[1])}">${subList1[0]}</td>
			<c:forEach items="${subList1[1]}"  var="subList2"  varStatus="status1">
					<c:if test="${status1.index==0}">
					<c:forEach items="${subList2}"  var="subList3"  varStatus="status2">
						<td>${subList3}</td>
					</c:forEach>
			</tr>
					</c:if>
					<c:if test="${status1.index>0}">
					<tr>
					<c:forEach items="${subList2}"  var="subList3"  varStatus="status2">
						<td>${subList3}</td>
					</c:forEach>
					</tr>
					</c:if>
			</c:forEach>
		</c:forEach>
	</table>
</body>
</html>

你可能感兴趣的:(jsp 按照数据规则输出类似合并单元格类型的数据)