jsp页面一行只显示两条记录的算法

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<%!
int[] i = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
%>
</head>

<body>


<div align="center">

</div>
<div align="center">
<table width="500" border="1" cellpadding="0" cellspacing="0">
<%
for(int j=0;j<i.length;j++){
%>
<%
if((j+1)%2 != 0){
%>
<!--DWLayoutTable-->
<tr>
<%
}
%>
<td width="250" height="146" valign="top"><table width="100%" border="1" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="250" height="39" valign="top"><%= i[j]%></td>
</tr>
<tr>
<td height="44" valign="top"><!--DWLayoutEmptyCell--><%= i[j]%></td>
</tr>
<tr>
<td height="39" valign="top"><!--DWLayoutEmptyCell--><%= i[j]%></td>
</tr>
<tr>
<td height="24" valign="top"><!--DWLayoutEmptyCell--><%= i[j]%></td>
</tr>
</table></td>
<% if((j+1)%2 == 0){
%>
</tr>
<%
}
%>
<%
}
%>
</table>
</div>
</body>
</html>

你可能感兴趣的:(jsp)