求救贴:碰到过的帮帮忙了javabean出现unable to compile class for jsp (在线等)
试验一个小小的javabean程序 可是老是出现错误 代码如下:
TestBean.java:
package test;
public class TestBean {
String name;
public TestBean(){}
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return this.name;
}
}
index.jsp
<%@ page language= "java " import= "test.TestBean " %>
<html>
<head>
<title> My JSP 'index.jsp ' starting page </title>
</head>
<body>
<jsp:useBean id= "testBeanEx " scope= "page " class= "TestBean "/>
</body>
</html>
运行信息:
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(7,1) The value for the useBean class attribute TestBean is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Generator.generate(Generator.java:3394)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
--------------------------------------------
Apache Tomcat/6.0.10
tomcat6.0 下localhost:8080运行正常 其中实例运行正常 HelloWorld.java运行正常
配置了好久 就是不知道问题在哪里 高手指点下吧
[解决办法]
<jsp:useBean id= "testBeanEx " scope= "page " class= "TestBean "/>
换
<%TestBean t = new TestBean();%>
试一下
[解决办法]
分析:
HelloWorld.java运行正常,说明jdk安装、配置正常;
tomcat6.0 下localhost:8080运行正常,其中实例运行正常说明tomcat安装、配置正常;
因此问题应该出现在例子本身。
在对TestBean编译后,Tomcat是否重启?
如果重启后问题依旧,则用 <%TestBean t = new TestBean();%> 方式试试看。
[解决办法]
你的class里面应该是你的TestBean的全路径吧,你只写了TestBean那它怎么找到改bean类呢!!
[解决办法]
楼上正解!
还是看看你的javabean程序所在的包,要路径引用的。
org.apache.jasper.JasperException: /WebRoot/index.jsp(7,1) The value for the useBean class attribute TestBean is invalid.
这个地方已经告诉你了,TestBean is invalid.无效!
[解决办法]
HTTP500...
看看是不是IE上的 "显示友好http错误信息 "那个是不是要勾掉
[解决办法]
上面说的这个应该是对的
: <jsp:useBean id= "test " scope= "page " class= "test.TestBean "> </jsp:useBean>
TestBean生成的类,要放在classes下的test目录下。
好象从Servlet2.3规范后用javabean必须用包,用包是一个好习惯,还是用吧
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html