| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 846 人关注过本帖
标题:[求助]为什么我的JavaBean不能正确运行?
只看楼主 加入收藏
flyxinqing
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-5-4
收藏
 问题点数:0 回复次数:2 
[求助]为什么我的JavaBean不能正确运行?
我编写了如下TestBean.java程序放在目录C:\Tomcat 5.5\webapps\ROOT\WEB-INF\classes下
public class TestBean
{
private String message="no message";
public String getMessage()
{
return(message);
}
public void setMessage(String message)
{
this.message=message;
}
}

然后编写如下TestBean.jsp程序放在目录C:\Tomcat 5.5\webapps\ROOT下

<html>
<head>
<title>Use the JavaBean</title>
</head>
<body>
<jsp:useBean id="test" class="TestBean"/>
<jsp:setProperty name="test" property="message" value="Hello,JSP!"/>
<h1>Message:<I>
<jsp:getProperty name="test" property="message"/>
</I></h1>
</body>
</html>

用Tomcat运行后出现如下页面

HTTP Status 500 -


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: 6 in the jsp file: /TestBean.jsp
Generated servlet error:
TestBean cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /TestBean.jsp
Generated servlet error:
TestBean cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /TestBean.jsp
Generated servlet error:
TestBean cannot be resolved to a type

An error occurred at line: 9 in the jsp file: /TestBean.jsp
Generated servlet error:
TestBean cannot be resolved to a type


 org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

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

An error occurred at line: 6 in the jsp file: /TestBean.jsp
Generated servlet error:
TestBean cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /TestBean.jsp
Generated servlet error:
TestBean cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /TestBean.jsp
Generated servlet error:
TestBean cannot be resolved to a type

An error occurred at line: 9 in the jsp file: /TestBean.jsp
Generated servlet error:
TestBean cannot be resolved to a type


 org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
 org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
 org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
 org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.



我的环境是jdk1.5.0+tomcat5.5,所有的变量配置也都没有问题,请教各位高手应该怎样正确运行JavaBean呢?
搜索更多相关主题的帖子: JavaBean message TestBean String 
2006-05-04 11:25
adu99
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2006-5-4
收藏
得分:0 
源代码有问题!!!
jsp:setProperty name="test" property="message" value="Hello,JSP!"/>
这一行好像有问题!

勤学如田中之禾,不见其长,日有所增……
2006-05-04 20:26
arcxixi
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-4-6
收藏
得分:0 
该是这条语句有问题,<jsp:useBean id="test" class="TestBean"/>
class="package.class",你在仔细看看jsp:useBean的用法

[此贴子已经被作者于2006-5-10 16:18:24编辑过]

2006-05-10 16:18
快速回复:[求助]为什么我的JavaBean不能正确运行?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.066949 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved