public class FirstBean
{
private String stringVar;
public String getStringThing()
{
return stringVar;
}
public void setStringThing(String s)
{
stringVar=s;
}
public FirstBean()
{
stringVar="";
}
}
FirstBean.jsp源文件
<%@ page import="FirstBean"%>
<jsp:useBean id="fb" class="FirstBean"/>
<jsp:setProperty name="fb" property="stringThing" value="Hello World"/>
<html>
<body>
<jsp:getProperty name="fb" property="stringThing"/>
</body>
</html>
运行环境 win2000sp4+tomcat5.0.19
错误提示
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: FirstBean
org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:122)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1053)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1079)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2230)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2236)
org.apache.jasper.compiler.Node$Root.accept(Node.java:485)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Generator.generate(Generator.java:3255)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.ClassNotFoundException: FirstBean
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1383)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1230)
org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:120)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1053)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1079)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2230)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2236)
org.apache.jasper.compiler.Node$Root.accept(Node.java:485)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Generator.generate(Generator.java:3255)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.19
------------------------------------
请帮忙.谢谢.
6 个解决方案
#1
兄弟,把你的bean放在一个包里面咯 。
这样:
package extam;
public class FirstBean
{
private String stringVar;
public String getStringThing()
{
return stringVar;
}
public void setStringThing(String s)
{
stringVar=s;
}
public FirstBean()
{
stringVar="";
}
}
FirstBean.jsp源文件
<%@ page import="exam.FirstBean"%>
<jsp:useBean id="fb" class="exam.FirstBean"/>
<jsp:setProperty name="fb" property="stringThing" value="Hello World"/>
<html>
<body>
<jsp:getProperty name="fb" property="stringThing"/>
</body>
</html>
^_^
这样:
package extam;
public class FirstBean
{
private String stringVar;
public String getStringThing()
{
return stringVar;
}
public void setStringThing(String s)
{
stringVar=s;
}
public FirstBean()
{
stringVar="";
}
}
FirstBean.jsp源文件
<%@ page import="exam.FirstBean"%>
<jsp:useBean id="fb" class="exam.FirstBean"/>
<jsp:setProperty name="fb" property="stringThing" value="Hello World"/>
<html>
<body>
<jsp:getProperty name="fb" property="stringThing"/>
</body>
</html>
^_^
#2
首先建议你的Bean打个包,package 包名
然后把你的包和包里的类文件放到WEB-INF\classes\目录下,重启Tomcat
再然后<%@ page import="包名.FirstBean"%>
试一试
MSN:cqhw2003@126.com
然后把你的包和包里的类文件放到WEB-INF\classes\目录下,重启Tomcat
再然后<%@ page import="包名.FirstBean"%>
试一试
MSN:cqhw2003@126.com
#3
FirstBean的路径不对!最好把他放到一个包里!没有包名,有时候好象是不行!我也碰到过,后来加上包名就可以了!
#4
程序没有问题啊。
不过有点罗嗦。
<%@ page import="FirstBean"%>完全可以去掉、。
不过有点罗嗦。
<%@ page import="FirstBean"%>完全可以去掉、。
#5
bean代码修改:
package com.soft.test;
public class FirstBean
{
private String stringVar;
public String getStringThing()
{
return stringVar;
}
public void setStringThing(String s)
{
stringVar=s;
}
public FirstBean()
{
stringVar="";
}
}
jsp代码修改:
<%@ page contentType="text/html;charset=gb2312" %>
<jsp:useBean id="fb" class="com.soft.test.FirstBean"/>
<jsp:setProperty name="fb" property="stringThing" value="Hello World"/>
<html>
<body>
<jsp:getProperty name="fb" property="stringThing"/>
</body>
</html>
OK!!
package com.soft.test;
public class FirstBean
{
private String stringVar;
public String getStringThing()
{
return stringVar;
}
public void setStringThing(String s)
{
stringVar=s;
}
public FirstBean()
{
stringVar="";
}
}
jsp代码修改:
<%@ page contentType="text/html;charset=gb2312" %>
<jsp:useBean id="fb" class="com.soft.test.FirstBean"/>
<jsp:setProperty name="fb" property="stringThing" value="Hello World"/>
<html>
<body>
<jsp:getProperty name="fb" property="stringThing"/>
</body>
</html>
OK!!
#6
都不能通过编译啊
请问
仅仅tomcat是否支持javabean
是否需要设置tomcat?
请问
仅仅tomcat是否支持javabean
是否需要设置tomcat?
#1
兄弟,把你的bean放在一个包里面咯 。
这样:
package extam;
public class FirstBean
{
private String stringVar;
public String getStringThing()
{
return stringVar;
}
public void setStringThing(String s)
{
stringVar=s;
}
public FirstBean()
{
stringVar="";
}
}
FirstBean.jsp源文件
<%@ page import="exam.FirstBean"%>
<jsp:useBean id="fb" class="exam.FirstBean"/>
<jsp:setProperty name="fb" property="stringThing" value="Hello World"/>
<html>
<body>
<jsp:getProperty name="fb" property="stringThing"/>
</body>
</html>
^_^
这样:
package extam;
public class FirstBean
{
private String stringVar;
public String getStringThing()
{
return stringVar;
}
public void setStringThing(String s)
{
stringVar=s;
}
public FirstBean()
{
stringVar="";
}
}
FirstBean.jsp源文件
<%@ page import="exam.FirstBean"%>
<jsp:useBean id="fb" class="exam.FirstBean"/>
<jsp:setProperty name="fb" property="stringThing" value="Hello World"/>
<html>
<body>
<jsp:getProperty name="fb" property="stringThing"/>
</body>
</html>
^_^
#2
首先建议你的Bean打个包,package 包名
然后把你的包和包里的类文件放到WEB-INF\classes\目录下,重启Tomcat
再然后<%@ page import="包名.FirstBean"%>
试一试
MSN:cqhw2003@126.com
然后把你的包和包里的类文件放到WEB-INF\classes\目录下,重启Tomcat
再然后<%@ page import="包名.FirstBean"%>
试一试
MSN:cqhw2003@126.com
#3
FirstBean的路径不对!最好把他放到一个包里!没有包名,有时候好象是不行!我也碰到过,后来加上包名就可以了!
#4
程序没有问题啊。
不过有点罗嗦。
<%@ page import="FirstBean"%>完全可以去掉、。
不过有点罗嗦。
<%@ page import="FirstBean"%>完全可以去掉、。
#5
bean代码修改:
package com.soft.test;
public class FirstBean
{
private String stringVar;
public String getStringThing()
{
return stringVar;
}
public void setStringThing(String s)
{
stringVar=s;
}
public FirstBean()
{
stringVar="";
}
}
jsp代码修改:
<%@ page contentType="text/html;charset=gb2312" %>
<jsp:useBean id="fb" class="com.soft.test.FirstBean"/>
<jsp:setProperty name="fb" property="stringThing" value="Hello World"/>
<html>
<body>
<jsp:getProperty name="fb" property="stringThing"/>
</body>
</html>
OK!!
package com.soft.test;
public class FirstBean
{
private String stringVar;
public String getStringThing()
{
return stringVar;
}
public void setStringThing(String s)
{
stringVar=s;
}
public FirstBean()
{
stringVar="";
}
}
jsp代码修改:
<%@ page contentType="text/html;charset=gb2312" %>
<jsp:useBean id="fb" class="com.soft.test.FirstBean"/>
<jsp:setProperty name="fb" property="stringThing" value="Hello World"/>
<html>
<body>
<jsp:getProperty name="fb" property="stringThing"/>
</body>
</html>
OK!!
#6
都不能通过编译啊
请问
仅仅tomcat是否支持javabean
是否需要设置tomcat?
请问
仅仅tomcat是否支持javabean
是否需要设置tomcat?