JSP程序的错误在哪里?
- 提问者网友:龅牙恐龙妹
- 2021-04-13 16:32
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:根下