各位大侠帮助小弟一下:The value for the useBean class attribute test.SayHi is invalid.

gshuai 2010-04-26 10:05:59
昨天晚上搞了一个通宵都没查原因,网上的方法能搜到的都试了

环境配置:
CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
PATH=C:\Sun\SDK\bin
JAVA_HOME=C:\Sun\SDK\jdk
tomcat安装位置:C:\Program Files\Apache Software Foundation\Tomcat 5.0
JDK安装位置:C:\Sun\SDK\jdk
-----------------------------------------------------------------------------------------------------
index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ page import="test.SayHi" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>javaBean</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

</head>

<body>
JavaBean <br>
<jsp:useBean id="test" class="test.SayHi"></jsp:useBean>
</body>
</html>

------------------------------------------------------------------------------------------------

JavaBean

package test;

public class SayHi {
String name="hi";
public SayHi()
{

}
public String getName()
{
return this.name;
}

}

------------------------------------------------------------------------------------
错误信息:
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: /WebRoot/index.jsp(19,4) The value for the useBean class attribute test.SayHi is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1227)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3272)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
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)


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


--------------------------------------------------------------------------------

Apache Tomcat/5.0.28
...全文
86 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
gshuai 2010-04-28
谢谢!
回复
rmbrmp 2010-04-26
index.jsp页面19行JavaBean属性test.SayHi无效.
1.看看你命名的这个“test”下,有没有SayHi属性。
2.如果test对应的class下有封装sayHi,那么看看有没有Getter和Setter
3.看看ActionForm里有没有test字段和对应属性
顺便说一下,你命名不规范。在Java里应该这样test.sayHi
回复
相关推荐
发帖
Java EE
创建于2007-09-28

6.6w+

社区成员

J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
申请成为版主
帖子事件
创建了帖子
2010-04-26 10:05
社区公告
暂无公告