java jsp页面表格展示 100
1个回答
展开全部
具体如下,有n条记录,在一个table表格中,每行显示5条记录,每个记录是个小图片,需要在第1个中显示第1个图片,第2个显示第2个图片……第n个显示第n个图片,代码如下:
首先,在web目录下新建一个pic目录,用于存放图片
[java] view plain copy
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'MyJsp.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<table>
<%
int n=101;
for(int i=1;i<=n;i++){
if(i%5==1){
%>
<tr>
<%
}
%>
<td><img src="/my_test/pic/hehe<%=i%>.jpg" /></td>
<%
if(i%5==0){
%>
</tr>
<%
}
}
%>
</table>
</body>
</html>
首先,在web目录下新建一个pic目录,用于存放图片
[java] view plain copy
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'MyJsp.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<table>
<%
int n=101;
for(int i=1;i<=n;i++){
if(i%5==1){
%>
<tr>
<%
}
%>
<td><img src="/my_test/pic/hehe<%=i%>.jpg" /></td>
<%
if(i%5==0){
%>
</tr>
<%
}
}
%>
</table>
</body>
</html>
追问
首先,我这里是有个日期在控制。每个月的天数不一样,下面表格的列数也会有相应变化。其次。数据是动态的,弄成图片算什么?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询