首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

求助:关于jsp文件无法调用Bean的有关问题,多谢

2013-09-11 
求助:关于jsp文件无法调用Bean的问题,谢谢!愚弟百思不得其解,请各位大虾相助!!!usebean.jsp文件置于D:\Tom

求助:关于jsp文件无法调用Bean的问题,谢谢!
愚弟百思不得其解,请各位大虾相助!!!

usebean.jsp文件置于D:\Tomcat   5.5\webapps\ROOT\目录下
源程序如下:
<%@   page   import   =   "test.TestBean "   %>
<jsp:useBean   id   = "test "   class   =   "test.TestBean ">
</jsp:useBean>
<%   test.setString1( "Hello ");
      test.setString2( "   world ");
%>
<%=   test.getString1Value()   %>
<br>
<%=   test.getString2Value()   %>


TestBean.java       置于D:\Tomcat   5.5\webapps\ROOT\WEB-INF\classes\test\目录下
源程序如下:
package   test;
public   class   TestBean{
private   String     string1   =   null;
private   String     string2   =   null;
public   TestBean()
{
}
public   void   setString1(String   value)
{
string1   =   value;
}
public   void   setString2(String   value)
{
string2   =   value;
}
public   String   getString1Value()
{
return   string1;
}
public   String   getString2Value()
{
return   string2;
}
}

Jdk环境已经配置好
Tomcat已经启动
在IE地址栏键入http://localhost:8080/usebean.jsp

出现以下错误提示:

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:   /usebean.jsp(4,0)   The   value   for   the   useBean   class   attribute   test.TestBean   is   invalid.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
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:   /usebean.jsp(4,0)   The   value   for   the   useBean   class   attribute   test.TestBean   is   invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1174)
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:3320)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
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:305)
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.20   logs.


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

Apache   Tomcat/5.5.20


刷新页面后又出现以下错误:

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   load   class   for   JSP
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
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   load   class   for   JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:598)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:147)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
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  

java.lang.ClassNotFoundException:   org.apache.jsp.usebean_jsp
java.net.URLClassLoader$1.run(Unknown   Source)
java.security.AccessController.doPrivileged(Native   Method)
java.net.URLClassLoader.findClass(Unknown   Source)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:133)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65)
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:596)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:147)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
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.20   logs.


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

Apache   Tomcat/5.5.20

请问这是哪里的问题   ?



[解决办法]
getString1Value和getString2Value, 改为:
getString1和getString2

------解决方案--------------------


按一楼的改下 在检查TestBean。CLASS是否存在与TEST中
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行