Topic: 我做的一个JAVABEN,提示有错误

  Print this page

1.我做的一个JAVABEN,提示有错误 Copy to clipboard
Posted by: badmanhd
Posted on: 2005-03-02 13:40

我按照如下的连接做的例子配置TOMCAT,
http://blog.china-pub.com/more.asp?name=cyqxyz&id=3144
错误提示如下:
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

Generated servlet error:
C:\tomcat5.0\work\Catalina\localhost\_\org\apache\jsp\TestBean_jsp.java:6: package test does not exist
import test.TestBean;
^

An error occurred at line: 3 in the jsp file: /TestBean.jsp
Generated servlet error:
C:\tomcat5.0\work\Catalina\localhost\_\org\apache\jsp\TestBean_jsp.java:46: cannot resolve symbol
symbol : class TestBean
location: class org.apache.jsp.TestBean_jsp
TestBean testBean=new TestBean("This is a test java bean.");
^

An error occurred at line: 3 in the jsp file: /TestBean.jsp
Generated servlet error:
C:\tomcat5.0\work\Catalina\localhost\_\org\apache\jsp\TestBean_jsp.java:46: cannot resolve symbol
symbol : class TestBean
location: class org.apache.jsp.TestBean_jsp
TestBean testBean=new TestBean("This is a test java bean.");
^
3 errors

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:437)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:497)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:476)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:464)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

2.Re:我做的一个JAVABEN,提示有错误 [Re: badmanhd] Copy to clipboard
Posted by: wenbin151
Posted on: 2005-03-04 10:19

在这个包中找不到!

3.Re:我做的一个JAVABEN,提示有错误 [Re: badmanhd] Copy to clipboard
Posted by: badmanhd
Posted on: 2005-03-04 13:49

上面那个程序的代码就是一个JAVA程序,很简单啊,如下, 文件名为TestBean.java,
将TestBean.java放在c:\test下,使用如下命令编译:
C:\Test>javac TestBean.java
然后在c:\Test下会产生一个编译后的bean文件:TestBean.class
将TestBean.class文件剪切到 %CATALINA_HOME%\webapps\myapp\WEB-INF\classes\test下

最后测试就会出现楼顶的问题,请问,是怎么回事啊?

package test;
public class TestBean{
private String name = null;
public TestBean(String strName_p){
this.name=strName_p;
}
public void setName(String strName_p){
this.name=strName_p;
}
public String getName(){
return this.name;
}
}

4.Re:我做的一个JAVABEN,提示有错误 [Re: badmanhd] Copy to clipboard
Posted by: 孤独王子
Posted on: 2005-03-07 22:31

javaBean不是这么用的
药用jsp:useBean id="" scope=""

5.Re:我做的一个JAVABEN,提示有错误 [Re: badmanhd] Copy to clipboard
Posted by: badmanhd
Posted on: 2005-03-08 12:00

楼上的意思,是调用那个BEAN的程序写的不对? 就是下面这个TestBean.jsp 的调用格式不对吗?

新建一个TestBean.jsp文件,文件内容为:
<%@ page import="test.TestBean" %>
<html><body><center>
<%
TestBean testBean=new TestBean("This is a test java bean.");
%>
Java bean name is: <%=testBean.getName()%>
</center></body></html>

6.Re:我做的一个JAVABEN,提示有错误 [Re: badmanhd] Copy to clipboard
Posted by: InnocentBoy
Posted on: 2005-03-10 07:36

我也是刚刚学习javabean,调试了好长时间才调试出来,我用的也是jsp:usebean。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923