List<String> titleList = getShowTitles(id);
		Page page = PageFactory.getPage(request);
		List<?> list = stYfdxQueryService.queryStYfdxQuery(
				stYfdxQueryQueryBean, page);
		request.setAttribute("titleList", titleList);
		request.setAttribute("titleListSize", titleList.size());
		request.setAttribute("list", list);
		request.setAttribute("page", page);
		request.setAttribute("queryBean", stYfdxQueryQueryBean);

 jsp:

<table width="100%" cellpadding="0" cellspacing="1"
						bgcolor="#a6c6da">
						<tr>
							<td  height="35" align="center" valign="middle" bgcolor="#ecf6ff">
								序号
							</td>
                        <c:forEach var="title" items="${titleList}" varStatus="ctIndex">
							<td  align="center" valign="middle" bgcolor="#ecf6ff">
								<c:out value="${title}"/>
							</td>
						</c:forEach>	
						</tr>

						<c:forEach var="bean" items="${list}" varStatus="ctIndex">
						   <tr>
                           <c:forEach begin="0" end="${titleListSize}" var="i">
							   <td height="35" align="center" valign="middle"
								  bgcolor="#FFFFFF">
								  <c:out value='${bean[i]}'/>
							   </td>
                            </c:forEach>
							</tr>
						</c:forEach>
					</table>

 

你可能感兴趣的:(foreach)