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

我受不了了!菜鸟搞了3天了,还是不正确!!!
我用myEclipse开发javaBean
在src上建了一个包com,com下建了bean类如下:
package   com;

public   class   Counter   {
public   Counter(){

}
private   int   count=0;

public   int   getCount(){
count++;
return   count;
}
public   void   setCount(int   newCount){
count=newCount;
}
}
jsp代码如下:
<%@   page   language= "java "   import= "java.util.* "   pageEncoding= "ISO-8859-1 "%>
<html>
    <head>        
        <title> My   JSP   'Count.jsp '   starting   page </title>
    </head>    
    <body>      
        <jsp:useBean   id= "myBean "   scope= "page "   class= "com.Counter "   />
        <%=   myBean.getCount()   %>    
    </body>
</html>
但是死活就是不正确!!
org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP

An   error   occurred   at   line:   28   in   the   jsp   file:   /WebProject/WebRoot/Count.jsp

Generated   servlet   error:
        [javac]   Compiling   1   source   file

D:\Tomcat   5.0\work\Catalina\localhost\allen\org\apache\jsp\WebProject\WebRoot\Count_jsp.java:49:   软件包   com   不存在
            com.Counter   myBean   =   null;
                  ^


An   error   occurred   at   line:   28   in   the   jsp   file:   /WebProject/WebRoot/Count.jsp

Generated   servlet   error:
D:\Tomcat   5.0\work\Catalina\localhost\allen\org\apache\jsp\WebProject\WebRoot\Count_jsp.java:51:   软件包   com   不存在
                myBean   =   (com.Counter)   pageContext.getAttribute( "myBean ",   PageContext.PAGE_SCOPE);
                                          ^


An   error   occurred   at   line:   28   in   the   jsp   file:   /WebProject/WebRoot/Count.jsp

Generated   servlet   error:
D:\Tomcat   5.0\work\Catalina\localhost\allen\org\apache\jsp\WebProject\WebRoot\Count_jsp.java:53:   软件包   com   不存在
                    myBean   =   new   com.Counter();
                                                    ^
3   错误

没有道理啊!我实在不知道什么原因了~请各位高手解释下!!!

------解决方案--------------------
在webapps目录下新建立一个目录Test,具体目录如下:

Test
-index.jsp
-WEB-INF
--web.xml
--classes
---Counter.class


然后