刚接触jsp,按照书上的程序试验一下,可出现了好多出错信息!

w_hb w_hb 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
主要功能是实现一个计数器,将访问者数量保存在count.txt中。
我把count.txt和count.jsp建在同一目录中
源代码如下:
count.jsp

<%@ page contentType="text/html;charset=GB2312"%>
<HTML>
<TITLE>计数器</TITLE>
<BODY>
<center>计数器</center>
<hr>
<%
String path =request.getRealPath("./");
FileReader fr=new FileReader(path+"count.txt");
BufferedReader br=new BufferedReader(fr);
String strNum=br.readLine();
br.close();
fr.close();
%>
<center>您是第<% =strNum% >位访问者。</center>
<%
FileWriter fw =new FileWriter(path+"count.txt");
int Num=Integer.parseInt(strNum)+1;
fw.write(String.valueOf(Num));
fw.close();
%>
</BODY>
</HTML>


运行后提示的信息:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 14 in the jsp file: /jsp/count.jsp

Generated servlet error:
[javac] Compiling 1 source file

D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:59: illegal start of expression
=strNum% >浣????????</center>
^

An error occurred at line: 14 in the jsp file: /jsp/count.jsp

Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:59: illegal character: \12290
=strNum% >浣????????</center>
^

An error occurred at line: 6 in the jsp file: /jsp/count.jsp

Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:51: cannot resolve symbol
symbol : class FileReader
location: class org.apache.jsp.count_jsp
FileReader fr=new FileReader(path+"count.txt");
^

An error occurred at line: 6 in the jsp file: /jsp/count.jsp

Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:51: cannot resolve symbol
symbol : class FileReader
location: class org.apache.jsp.count_jsp
FileReader fr=new FileReader(path+"count.txt");
^

An error occurred at line: 6 in the jsp file: /jsp/count.jsp

Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:52: cannot resolve symbol
symbol : class BufferedReader
location: class org.apache.jsp.count_jsp
BufferedReader br=new BufferedReader(fr);
^

An error occurred at line: 6 in the jsp file: /jsp/count.jsp

Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:52: cannot resolve symbol
symbol : class BufferedReader
location: class org.apache.jsp.count_jsp
BufferedReader br=new BufferedReader(fr);
^

An error occurred at line: 14 in the jsp file: /jsp/count.jsp

Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:63: cannot resolve symbol
symbol : variable fw
location: class org.apache.jsp.count_jsp
fw.write(String.valueOf(Num));
^

An error occurred at line: 14 in the jsp file: /jsp/count.jsp

Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:64: cannot resolve symbol
symbol : variable fw
location: class org.apache.jsp.count_jsp
fw.close();
^

An error occurred at line: 14 in the jsp file: /jsp/count.jsp

Generated servlet error:
Note: D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
8 errors

...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
w_hb
Web 开发 81,108 成员 341,721 内容