永发信息网

JSP程序的错误在哪里?

答案:1  悬赏:40  手机版
解决时间 2021-04-14 08:52
  • 提问者网友:龅牙恐龙妹
  • 2021-04-13 16:32
<%@ page language="java" contentType="text/html; charset=GB18030" import="java.lang.* ,java.io.*"
pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>网站计数器</title>
</head>
<body>
<%
String record = null;
BufferedReader br = null;
String FilePath = "E:\\WEB实验\\count.txt";
PrintWriter pw = null;
%>
<%
br = new BufferedReader(new FileReader(FilePath));
record = br.readLine();

if(record == null){
record = "1";
}else{
record = (Integer.parseInt(record) + 1) + "";
}
%>

<h1 align="center"> 您是第<%= record %>个访问者,欢迎下次在来!!!!!!!</h1>
<%
pw = new PrintWriter(new FileOutputStream(FilePath));
pw.write(record);
pw.close();
%>

</body>
</html>
最佳答案
  • 五星知识达人网友:神鬼未生
  • 2021-04-13 17:16

测试你的代码了,没有问题


<%@ page language="java" contentType="text/html; charset=GB18030" import="java.lang.* ,java.io.*"
pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>网站计数器</title>
</head>
<body>
<%
String record = null;
BufferedReader br = null;
String FilePath = "c:\\count.txt";
PrintWriter pw = null;
%>
<%
br = new BufferedReader(new FileReader(FilePath));
record = br.readLine();


if(record == null){
record = "1";
}else{
record = (Integer.parseInt(record) + 1) + "";
}
%>


<h1 align="center"> 您是第<%= record %>个访问者,欢迎下次在来!!!!!!!</h1>
<%
pw = new PrintWriter(new FileOutputStream(FilePath));
pw.write(record);
pw.close();
%>


</body>
</html>






对了,我知道了,你把String FilePath = "E:\\WEB实验\\count.txt";




中文改成英文就可以了,像我那么写放到C:根下

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯