日期:2014-05-18  浏览次数:20733 次

JSP页面调用JavaBean问题[急急急!!!]
我写了一个JavaBean,源代码如下
package   PK_HelloWorld;
public   class   HelloWorld{  
public   HelloWorld(){}  
      public   static   void   main(String[]   args){
              System.out.print( "Hello   World!!!!!\n ");
             
      }
}
并生成类HelloWorld.class。
写了一个Jsp页面调用这个javabean,源代码如下
<%@   page   contentType= "text/html;charset=UTF-8 "   %>    
<jsp:useBean   id= "sessionBean1 "   scope= "page "   class= "uo.HelloWorld "/> <html>
<head>
<title> DDDDDDDDDDDDDD </title>
</head>
<table> <tr>
<td>
dfsfdsfdsd
<%
System.out.print( "AAAAAxcAAAAAA ");
//sessionBean1.setUserId(userid);     //useridˇjavaτ&frac14;&#65533;&#65533;
%>
</td>
</tr> </table>
</html>
结果在条用页面出现以下提示
org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP

An   error   occurred   at   line:   -1   in   the   jsp   file:   null

Generated   servlet   error:
        [javac]   Compiling   1   source   file
        [javac]   D:\jboss-3.2.2RC4\server\default\work\MainEngine\localhost\wl\default_on_jsp.java:42:   cannot   access   uo.HelloWorld
        [javac]   bad   class   file:   D:\jboss-3.2.2RC4\server\default\deploy\wl.war\WEB-INF\classes\uo\HelloWorld.class
        [javac]   class   file   contains   wrong   class:   PK_HelloWorld.HelloWorld
        [javac]   Please   remove   or   make   sure   it   appears   in   the   correct   subdirectory   of   the   classpath.
        [javac]               uo.HelloWorld   sessionBean1   =   null;
        [javac]                   ^
        [javac]   1   error

我的Web   Server是jboss-3.2.2RC4,哪位高人提点意见呀


------解决方案--------------------
package错了
------解决方案--------------------
你的包路径不是PK_HelloWorld么,怎么在jsp中引入的路径却是uo.HelloWorld。这里不对
------解决方案--------------------
<jsp:useBean id= "sessionBean1 " scope= "page " class= "PK_HelloWorld.HelloWorld "/>

------解决方案--------------------
我将你的代码下下来测试了一下,发现将 <jsp:useBean id= "sessionBean1 " scope= "page " class= "uo.HelloWorld "/> 改成 <jsp:useBean id= "sessionBean1 " scope= "page " class= "PK_HelloWorld.HelloWorld "/> 就可以成功编译并运行。
------解决方案--------------------
怎么搞的啊.放在uo中,代码上又写package PK_HelloWorld;

应该是jboss-3.2.2RC4\server\default\deploy\wl.war\WEB-INF\classes\PK_HelloWorld

或者是把package PK_HelloWorld;换成package uo;