jsp无法打开页面

feihanyu 2007-12-05 11:51:17
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%
File f=new File("count.txt");
//FileReader fr=new FileReader(f);
%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
this is test
</body>
</html>

这样可以打开,如果把注释去掉,就会出现“无法显示网页”
请问这是为什么?
...全文
321 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
feihanyu 2007-12-07
  • 打赏
  • 举报
回复
感谢各位,将代码放到<body>……</body>中我没有试,但是我解决的方法是:捕获异常。
linxi1151 2007-12-05
  • 打赏
  • 举报
回复
File f=new File("count.txt");
的路径有问题;
String path = request.getRealPath("/");
File f = new File(path+"count.txt");
这样就能找到路径了
xiaochuan225 2007-12-05
  • 打赏
  • 举报
回复
学习!
zazxzx 2007-12-05
  • 打赏
  • 举报
回复
<%@       page       language="java"       contentType="text/html;       charset=ISO-8859-1"   
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title> Insert title here </title>
</head>
<body>
<%
File f=new File("count.txt");
//FileReader fr=new FileReader(f);
%>
this is test
</body>
</html>
wuy13862574600 2007-12-05
  • 打赏
  • 举报
回复
。。。晕掉,就不会用论坛的的着色插件功能啊。。
排版乱七八糟的。
  • 打赏
  • 举报
回复
我改了一下代码:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title> Insert title here </title>
</head>
<body>
<%
File f=new File("count.txt");
//FileReader fr=new FileReader(f);
%>
this is test
</body>
</html>



一般来说
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
这两个部分是同时放在最前面的,然后:



<%
File f=new File("count.txt");
//FileReader fr=new FileReader(f);
%>
这部分代码是放在<body> </body>标签里面的,
这样改了之后就不会出现你刚才说的问题了

62,623

社区成员

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

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