利用Java程序片,用for二重循环输出一个3行5列的table
考察JSP程序片和HTML代码结合使用
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'index.jsp' starting page</title> <link rel="stylesheet" type="text/css" href="styles.css"> <style> table{ 500px; height:300px; text-align:center } </style> </head> <%!int i, j;%> <body> <h3>for二重循环输出一个3行5列的table</h3> <table border="1" cellpadding="0" cellspacing="0"> <% for(i=1;i<=3;i++){ %> <tr> <% for(j=1;j<=5;j++){ %> <td>table</td> <% } %> </tr> <% } %> </table> </body> </html>