代码如下:
<html>
<head><title>Rubbit</title></head>
<body>
<%!
int fir[]=new int[13];
fir[0]=0;
fir[1]=1;
%>
<% for(int i=1;i<=12;i++)
{%>
<br><%=i%>月:<%=fir[i-2]+fir[i-1]%> 对
<%}%>
</body>
</html>
出错了,错误提示是:
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: -1 in the jsp file: nullGenerated servlet error:
[javac] Compiling 1 source fileD:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Rubbit_jsp.java:12: ']' expected
fir[0]=0;
^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Rubbit_jsp.java:12: <identifier> expected
fir[0]=0;
^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Rubbit_jsp.java:13: ']' expected
fir[1]=1;
^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Rubbit_jsp.java:13: <identifier> expected
fir[1]=1;
^
4 errors
请问是什么原因啊?
谢谢高手帮助啊
<html>
<head><title>Rubbit</title></head>
<body>
<%!
int fir[]=new int[13];
fir[0]=0;
fir[1]=1;
%>
<% for(int i=1;i<=12;i++)
{%>
<br><%=i%>月:<%=fir[i-2]+fir[i-1]%> 对
<%}%>
</body>
</html>
出错了,错误提示是:
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: -1 in the jsp file: nullGenerated servlet error:
[javac] Compiling 1 source fileD:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Rubbit_jsp.java:12: ']' expected
fir[0]=0;
^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Rubbit_jsp.java:12: <identifier> expected
fir[0]=0;
^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Rubbit_jsp.java:13: ']' expected
fir[1]=1;
^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\Rubbit_jsp.java:13: <identifier> expected
fir[1]=1;
^
4 errors
请问是什么原因啊?
谢谢高手帮助啊
<%!
int fir[]=new int[13];
fir[0]=0;
fir[1]=1;
%>这样会占用系统内存的!!!
int fir[]=new int[13];
fir[0]=0;
fir[1]=1;
%>
----------------
<%! %>
代表声明
fir[0]=0;fir[1]=1;怎么可以放在声明中呢?
应该这样将fir[0]=0;fir[1]=1;放置于<%%>之中如:
public class Test
{
int[] fir = new int[10];
//fir[0]=0; //error
//fir[1]=1; //error
public Test()
{
fir[0]=0; //ok
fir[1]=1; //ok
}
}
<html>
<head><title>Rubbit</title></head>
<body>
<%! int fir[]=new int[13];%>
<% fir[0]=0;
fir[1]=1;%>
<% for(int i=1;i<=12;i++)
{%>
<%if(i==2){%>
<br><%=i%> :<%=fir[i-2]+fir[i-1]%>
<%}%>
<%}%>
</body>
</html>
运行后通过,但是显示的是下面的东西,如下:
2 £º1
辛苦大家一下再帮我看看,谢谢了。
2.如果你是用j9的话 建议到ie上去测试 如 http:\\127.0.0.1\.....\xxx.jsp
你可以将代码这么写:
<html>
<head><title>Rubbit</title></head>
<body>
<%! int fir[]=new int[13];%>
<% fir[0]=0;
fir[1]=1;%>
<% for(int i=1;i<=12;i++)
{%>
<%if(i==1)%>
<br>
<%=i%>:<%=fir[i]%>
<% else{%>
<br><%=i%>:<%=fir[i-1+fir[i-2]%>
<%}
}%>
<%}%>
</body>
</html>
照你的 算法 只有当 i=2时才会运行一次
其他的都不会有结果~~
并且 当 i=1时 i-2会出问题~~
我是初学者
谢谢大家的帮助
弄完了
贴出来给大家看一下
<html>
<head><title>Rubbit</title></head>
<body>
<%! int fir[]=new int[13];
int y;%>
<% fir[0]=0;
fir[1]=1;
fir[2]=1;%>
<br><%=1%>:<%=fir[1]%>
<br><%=2%>:<%=fir[2]%>
<% for(int i=1;i<=10;i++)
{%>
<% fir[1]=fir[1]+fir[2];
fir[2]=fir[1]+fir[2];
y=i+3;
%>
<br><%=i+++2%>:<%=fir[1]%>
<br><%=y%>:<%=fir[2]%>
<%}%>
</body>
</html>