读书人

初学jsp这断程序错在哪?多谢

发布时间: 2011-12-25 23:21:20 作者: rapoo

初学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>
<%
}
}%>

漏了一个 }

读书人网 >Java Web开发

热点推荐