日期:2014-05-18  浏览次数:20662 次

初学jsp,这断程序错在哪?谢谢
<%@ page language="java" pageEncoding="GBK"%>
<jsp:directive.page import=""/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>"打印测试"</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>
  <%char dia[][] ={{' ',' ',' ',' ',' ',' ','*',' ',' ',' ',' ',' ',' '},
{' ',' ',' ',' ','*','*','*','*','*',' ',' ',' ',' '},
{' ',' ',' ','*','*','*','*','*','*','*',' ',' ',' '},
{' ',' ','*','*','*','*','*','*','*','*','*',' ',' '},
{' ','*','*','*','*','*','*','*','*','*','*','*',' '},
{'*','*','*','*','*','*','*','*','*','*','*','*','*'}
};
  %>
  <h4>
<%for(int i=0;i<dia.length;i++){
for(int j = 0;j < dia[i].length;j++){
%>
<%=dia[i][j] %>
你好<br>
<%
}
%>  
  </h4>
   
  </body>
</html>


------解决方案--------------------
数组还是好好学学吧
行的数目必须定义

for的条件不能用dia.length因为你的是多维数组
------解决方案--------------------
<%
for(int i=0;i <dia.length;i++){ 
for(int j = 0;j < dia[i].length;j++){ 
%> 
<%=dia[i][j] %> 
你好 <br> 
<% 

}%> 

漏了一个 }