百思不得其解,无法使用javabean,高分求教

postform999 postform999 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我搜索了板块上关于无法使用javabean的帖子,发现还是无法解决我的问题,描述如下:
虚拟目录myapp
jsp放在myapp/下,不调用bean时,可以正常访问,servlet也可以正常访问
写了一个bean如下
package beans;
public class hello
{
public hello()
{
System.out.println("Hello!");
}

}

编译以后,把hello.class放在myapp/WEB-INF/classes/beans/ 下
然后写了一个test.jsp放在myapp/ 下,其中有
<jsp:useBean id="s" scope="page" class="beans.hello"/>
<%
s.hello();
%>

运行test.jsp,错误如下:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 9 in the jsp file: /1.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\tools\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\_1_jsp.java:42: cannot access beans.hello



An error occurred at line: 9 in the jsp file: /1.jsp

Generated servlet error:
bad class file: D:\work\programme\JSP\WEB-INF\classes\beans\hello.class
class file contains wrong class: hello
Please remove or make sure it appears in the correct subdirectory of the classpath.
beans.hello s = null;
^
1 error

...全文

相关推荐

评论 22
收藏 已收藏
分享
返回顶部
postform999
Web 开发 81,108 成员 341,721 内容