在tomcat的文件目录下的根目录的webapps\ROOT\WEB-INF下没有classes文件夹,我新建了一个classes文件夹,然后在新建自己的要用的.class文件如:chatroom\online.class.但是编译的时候提示说:The value for the useBean class attribute chatroom.online is invalid.怎么回事啊?搞不懂,知道的快点告诉我啊,急啊!

解决方案 »

  1.   

    你的 jsp 文件在哪里?
    把你的useBean 代码贴上来看看!
      

  2.   

    jsp是放在webapps\Myweb目录下的,useBean如下:
    package chatroom;
    import java.util.*;
    import java.sql.*;
    public class conn{
      String dbDriver="com.mysql.jdbc.Driver";
      String dbName="jdbc:mysql://localhost:3306/chat";
      ResultSet rs=null;
      Connection conn=null;
      Statement stmt=null;
      public conn(){
        try{
             Class.forName("dbDriver");
         }
        catch(ClassNotFoundException e1){
          System.err.println("Class not found!"+e1.getMessage());
         }
        try{
              conn=DriverManager.getConnection(dbName);
        }
        catch(SQLException e2){
          System.err.print(e2);
        }
    }
    public ResultSet executeQuery(String sql){
      rs=null;
      try{
      conn=DriverManager.getConnection(dbName,"root","root");
      stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
      rs=stmt.executeQuery(sql);
      }catch(SQLException e3){
        System.err.print(e3);
      }
      return rs;
    }public int excuteUpdate(String sql){
    int rt=0;
    try{
      conn=DriverManager.getConnection(dbName,"root","root");
      stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); 
      rt=stmt.executeUpdate(sql);
      }catch(SQLException e4){
        System.err.print(e4);
      }
    return rt;
    }public void close(){
      try{
        if(conn!=null)
             conn.close();
      }catch(Exception e){
        System.out.print(e);
      }try{
        if(rs!=null)
             rs.close();
      }catch(Exception e){
        System.out.println(e);
      }
    }}
      

  3.   

    package chatroom;
    public class online
    {
      private String uName[];
      private String uNickName[];
      private String uSex[];
      public String room;
      private int total;
      public online()
      {  
        uName=new String[50];
        uNickName=new String[50];
        uSex=new String[50];
        room=null;
        total=0;
      }
      public void add(String UserName,String NickName,String Sex)
      {
      if(total<50)
      {
      uName[total]=UserName;
      uNickName[total]=NickName;
      uSex[total]=Sex;
      total++;
      }
      }
      public void delete(String UserName)
      {
      for(int i=0;i<total;i++)
      
      if(uName[i].equals(UserName))
      {
      for(int j=i;j<total-1;j++)
      {
      uName[j]=uName[j+1];
      uNickName[j]=uNickName[j+1];
      uSex[j]=uSex[j+1];
      }
      total--;
      }
     
      }
      public int find(String UserName)
      {
      for(int i=0;i<total;i++)
      {
      if(uName[i].equals(UserName))
      return(i+1);
      if(i==(total-1))
      return 0;
      }
      return 0;
      }
      
      public String getuName(int num)
      {
      if(num<50)
      return uName[num];
      return null;
      }
      
      public String getuNickName(int num)
      {
      if(num<50)
      return uNickName[num];
      return null;
      }
      
      public String getuSex(int num)
      {
      if(num<50)
      return uSex[num];
      return null;
      }
      
      public int gettotal()
      {
      return total;
      }
      
      public String getroom()
      {
      return room;
      }
      
      public void setroom(String str)
      {
      this.room=str;
      }
      
    }
      

  4.   

    你的class文件应该在你的webapps\Myweb\WebRoot\WEB-INF\class下面
      

  5.   

    你的 jsp 文件在哪里?
    把你的useBean 代码贴上来看看!我没说清楚,我是要你的jsp里面的useBean代码,就是
    <jsp:useBean 的这一行
      

  6.   

    <jsp:useBean id="login" class="chatroom.conn" scope="application"/>
    <jsp:useBean id="online" class="chatroom.online" scope="application"/>
      

  7.   

    <jsp:useBean id="login" class="chatroom.conn" scope="application"/>
    <jsp:useBean id="online" class="chatroom.online" scope="application"/>