Tomcat4.1中的bean,请指教

kongbaby 2003-12-22 11:23:41
bean文件存放于D:\tomcat\webapps\test\WEB-INF\classes下,并且编译成功
jsp文件存放于D:\tomcat\webapps\test下
bean:
public class Counter
{
int count = 0;
public Counter()
{
}
public void setCount(int count)
{
this.count=count;
}
public int getCount()
{
count++;
return this.count;
}
}
jsp:
<html>
<head>
<title>简单记数器</title>
</head>
<body>
<jsp:useBean id="name0" scope="application" class="Counter"/>
The Counter is:
<%
out.println(name0.getCount());
%>
<br>
</body>
</html>
非常简单了吧,可是启动tomcat然后运行时候
报错:
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] D:\tomcat\work\Standalone\localhost\test\counter_jsp.java:47: cannot resolve symbol
[javac] symbol : class Counter
[javac] location: class org.apache.jsp.counter_jsp
[javac] Counter name0 = null;
[javac] ^
[javac] D:\tomcat\work\Standalone\localhost\test\counter_jsp.java:49: cannot resolve symbol
[javac] symbol : class Counter
[javac] location: class org.apache.jsp.counter_jsp
[javac] name0 = (Counter) pageContext.getAttribute("name0", PageContext.APPLICATION_SCOPE);
[javac] ^
[javac] D:\tomcat\work\Standalone\localhost\test\counter_jsp.java:52: cannot resolve symbol
[javac] symbol : class Counter
[javac] location: class org.apache.jsp.counter_jsp
[javac] name0 = (Counter) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "Counter");
[javac] ^
[javac] 3 errors


请大侠指点,小弟郁闷死了
...全文
17 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
凋零的老树 2003-12-22
  • 打赏
  • 举报
回复
bean一般class的某个文件夹下面,并在bean前面加上package 文件夹名称
jinsfree 2003-12-22
  • 打赏
  • 举报
回复
不过这样你每次都是1,呵呵。
jinsfree 2003-12-22
  • 打赏
  • 举报
回复
还是路径不对啦
你试一试把它放在一个包里面调用试试,肯定没有问题

81,092

社区成员

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

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