1.Count类
import java.io.Serializable;
public class Count implements Serializable
{
public int count=0; public void setCount(int count)
{
this.count=count;
} public int getCount()
{
return count;
} public void increment()
{
count++;
}
}
编译好以后,放在tomcat的root下的classes里面.
2.jsp文件
<html>
<body bgcolor="#ffffff">
<jsp:useBean id="count1" class="Count" scope="page" />
<jsp:useBean id="count2" class="Count" scope="page" /> Count1:<br>
<% count1.increment(); %>
You are visitor number <%=count1.getCount() %><p> Count2:<br>
<% count2.increment(); %>
You are visitor number <%=count2.getCount() %><p>
<body>
</html>
放在root下,然后运行这个JSP文件就出错啦.错误提示:
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 3 in the jsp file: /10.jspsymbol : class Count
location: class org.apache.jsp._10_jsp
Count count1 = null;
^
import java.io.Serializable;
public class Count implements Serializable
{
public int count=0; public void setCount(int count)
{
this.count=count;
} public int getCount()
{
return count;
} public void increment()
{
count++;
}
}
编译好以后,放在tomcat的root下的classes里面.
2.jsp文件
<html>
<body bgcolor="#ffffff">
<jsp:useBean id="count1" class="Count" scope="page" />
<jsp:useBean id="count2" class="Count" scope="page" /> Count1:<br>
<% count1.increment(); %>
You are visitor number <%=count1.getCount() %><p> Count2:<br>
<% count2.increment(); %>
You are visitor number <%=count2.getCount() %><p>
<body>
</html>
放在root下,然后运行这个JSP文件就出错啦.错误提示:
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 3 in the jsp file: /10.jspsymbol : class Count
location: class org.apache.jsp._10_jsp
Count count1 = null;
^
解决方案 »
- 一个小功能的实现,求高手赐教
- 关于scanner读写系统输入的问题
- 求一段java程序(一个随机字符串),一天内结帖
- ==关于setLayout(null)后的问题==高手救命!
- 运行javaapplet需要下载java2runtime吗
- 救命啊,我搞了一天了,还不行,socket提示IOException: invalid stream header
- 水平如何?
- 请问 pathclass设置正确 语法正确 编译通过 但在执行时 显示"Exception in thread "main" java.lang.NoClassDefFoundError"…………不解
- 一个很奇怪的问题.请进来看看吧.
- 有人用intellij idea吗?code review的插件有吗?
- 状态模式和策略模式的本质区别在哪里?
- 菜鸟救助TextField(30)中的代表什么意思?
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 3 in the jsp file: /10.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\work\Catalina\localhost\_\org\apache\jsp\_10_jsp.java:45: cannot resolve symbol
symbol : class Count
location: class org.apache.jsp._10_jsp
Count count1 = null;
^
你把类加一个包看看呢!假如:
类中:pakeage test;
jsp中:
<jsp:useBean id="count1" class="test.Count" scope="page" />