一个奇怪的jsp初级问题

cherevan 2004-08-26 08:31:25
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<title>Counter Version 1.0</title>
</head>

<body background="#ffffff">

<%@page import="java.io.*"%>
<%
BufferedReader file;
String countFile="C:\jakarta-tomcat-5.0.19\webapps\myproject\count.txt";
file = new BufferedReader(new FileReader(countFile));
String readStr = null;
int writeStr=1;
try
{readStr = file.readLine();
}
catch(IOException e)
{
System.out.println("error when try to read data!!!");

}
if (readStr == null)
readStr = "no record!!!";
else
{
writeStr = Integer.parseInt(readStr)+1;
}
try
{ PrintWriter pw;
pw = new PrintWriter(new FileOutputStream(countFile));
pw.println(writeStr);
pw.close();
}
catch(IOException e)
{
out.println(e.getMessage());
}
%>
<p align="center">
<H1>visitors' counter:</H1>
<H3>you are the
<font size="7" color="#804000">
<%=readStr%>
</font>that visit this website!!! </h3>

</body>
</html>

就是一个简单的程序计数器,我把那个count.txt放在和这个文件相同的目录下,但是她说找不到,
然后又改称绝对路径,他说:


C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\myproject\org\apache\jsp\Text_jsp.java:56: illegal escape character
String countFile="C:\jakarta-tomcat-5.0.19\webapps\myproject\count.txt";
^
郁闷,真是为了什么,高手知道一下,谢谢
!!!

...全文
128 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingting 2004-08-26
  • 打赏
  • 举报
回复
用相对路径比较好
david_chenyusi 2004-08-26
  • 打赏
  • 举报
回复
有谁知道JSP论坛的字符串怎么处理,就象上贴一样不回出错
david_chenyusi 2004-08-26
  • 打赏
  • 举报
回复
<font size=8>测试</font>
joincsdn 2004-08-26
  • 打赏
  • 举报
回复
String countFile="C:\\jakarta-tomcat-5.0.19\\webapps\\myproject\\count.txt";
bluesky35 2004-08-26
  • 打赏
  • 举报
回复
要用\\
spiritsl 2004-08-26
  • 打赏
  • 举报
回复
应该这样使用 \\
或者使用 /
这两个符号等价

但是一个 \ 是转意符

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧