自定义的两个java包互相不能访问,甚至同一个包中的java文件相互之间也不能调用。 请问是  什么问题,应该怎么解决? 我的环境变量:
 classpath :.;D:\Java\jdk1.6.0_18\lib\tools.jar;D:\Java\jdk1.6.0_18\lib\dt.jar   JAVA_HOME : D:\Java\jdk1.6.0_18   Path : D:\Java\jdk1.6.0_18\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;C:\Program Files\Microsoft SQL Server\80\Tools\BINN 
  然后我定义的两个包的路径是:  C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes
  的下面,一个是  comm 文件夹,一个是  Information  文件夹。  但是 当浏览器的地址栏输入 http://localhost:9090/myapp/index.jsp  时,就说找不到
 Information 和 comm 中的 类 。  请问这到底怎么解决呢?????

解决方案 »

  1.   

    异常信息如下: HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
    User cannot be resolved to a type
    39:  public String getName(String Userid)throws Exception
    40:  {
    41:    try{
    42:  User o_user = new User();
    43:  o_user.setUserId(Userid);
    44:  if(o_user.getUser())
    45:    {
    An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
    User cannot be resolved to a type
    39:  public String getName(String Userid)throws Exception
    40:  {
    41:    try{
    42:  User o_user = new User();
    43:  o_user.setUserId(Userid);
    44:  if(o_user.getUser())
    45:    {
    An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
    User cannot be resolved to a type
    39:  public String getName(String Userid)throws Exception
    40:  {
    41:    try{
    42:  User o_user = new User();
    43:  o_user.setUserId(Userid);
    44:  if(o_user.getUser())
    45:    {
    An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
    User cannot be resolved to a type
    39:  public String getName(String Userid)throws Exception
    40:  {
    41:    try{
    42:  User o_user = new User();
    43:  o_user.setUserId(Userid);
    44:  if(o_user.getUser())
    45:    {
    An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
    User cannot be resolved to a type
    39:  public String getName(String Userid)throws Exception
    40:  {
    41:    try{
    42:  User o_user = new User();
    43:  o_user.setUserId(Userid);
    44:  if(o_user.getUser())
    45:    {
    An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
    User cannot be resolved to a type
    39:  public String getName(String Userid)throws Exception
    40:  {
    41:    try{
    42:  User o_user = new User();
    43:  o_user.setUserId(Userid);
    44:  if(o_user.getUser())
    45:    {
    An error occurred at line: 30 in the jsp file: /left.jsp
    Categories cannot be resolved to a type
    27:  //如果是管理员,则可以设置用户信息,如果是其他用户则可以更改自己的密码
    28:  // 定义用户对象
    29:  Vector v_Cate = new Vector();
    30:  Categories o_Cate = new Categories();
    31:  v_Cate = o_Cate.getMoreCategories();
    32:  for(int i=0;i<v_Cate.size();i++)
    33:  {
    An error occurred at line: 30 in the jsp file: /left.jsp
    Categories cannot be resolved to a type
    27:  //如果是管理员,则可以设置用户信息,如果是其他用户则可以更改自己的密码
    28:  // 定义用户对象
    29:  Vector v_Cate = new Vector();
    30:  Categories o_Cate = new Categories();
    31:  v_Cate = o_Cate.getMoreCategories();
    32:  for(int i=0;i<v_Cate.size();i++)
    33:  {
    An error occurred at line: 34 in the jsp file: /left.jsp
    Categories cannot be resolved to a type
    31:  v_Cate = o_Cate.getMoreCategories();
    32:  for(int i=0;i<v_Cate.size();i++)
    33:  {
    34:  o_Cate = (Categories)v_Cate.elementAt(i);
    35:  %>
    36: <tr><td align="center"><a href="infoList.jsp?cid=<%=o_Cate.getCateId()%>" target="main" style="text-decoration: none"><%=o_Cate.getCateTitle()%></a></td></tr>
    37: <% }%>
    Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:319)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.28 logs.
    --------------------------------------------------------------------------------Apache Tomcat/5.5.28
      

  2.   

    InfoComm.jsp: <%@page import="java.text.*,java.util.Date,java.util.*,java.lang.*,java.io.*,Information.*,comm.*"%> 
    <%! 
    public final int MaxPerPage = 20; //每页信息个数 
    public String IMG_SITE; 
    public String IMG_LABLE_F = " <P[space]align=center> <IMG[space]SRC="; 
    public String IMG_LABLE_L = "> </P> <p>"; 
    public String strBG1="#FFFFFF"; 
    public String strBG2="#FEEC85"; 
    public String strbg; //替换字符串中的字符 
    public static String replaceString(String origStr, String oldStr, String newStr) { 
          if (origStr == null || origStr.length() == 0 || oldStr == null || 
              oldStr.length() == 0 || newStr == null) { 
              return origStr; 
          } 
          StringBuffer buffer = new StringBuffer(); 
          // find the oldStr's place in origStr 
          while (origStr.indexOf(oldStr) != -1) { 
              int index = origStr.indexOf(oldStr); 
      buffer.append(origStr.substring(0, index)); 
      buffer.append(newStr); 
      origStr = origStr.substring(index+oldStr.length()); 
        } 
          buffer.append(origStr); 
          return buffer.toString(); 
      } 
    // 判断是否为新信息 
    boolean isNew(String adate) 

    Calendar c=Calendar.getInstance(); 
    SimpleDateFormat thismonth = new SimpleDateFormat("yyyy-MM-dd"); 
    c.add(Calendar.DATE, -3); 
    String slastday=thismonth.format(c.getTime()); if(slastday.compareTo(adate) <=0) return true; 
    else return false; 

    public String getName(String Userid)throws Exception 

      try{ 
    User o_user = new User(); 
    o_user.setUserId(Userid); 
    if(o_user.getUser()) 
      { 
    return o_user.getEmplName(); 
      } 
      }catch(Exception e) 
            {System.out.println(e.toString());} 
      return ""; 

    // 判断用户是否存在 
    public boolean IsUser(String userid,String passwd)throws Exception 

    try{ 
    if(userid.length()==0 || passwd.length()==0) 
    return false; 
    else{ 
    // 定义用户对象,设置其用户名和密码 
    User o_user = new User(); 
    o_user.setUserId(userid); 
    o_user.setPassWord(passwd); 
    // 判断是否存在此用户信息,如果存在此用户则返回true 
    if(o_user.getUser()) 
    {System.out.print("pppp"); 
    return true; 


    }catch(Exception e){ 
    e.printStackTrace(); 

    return false; 

    // 判断用户类型 
    public int getType(String userid)throws Exception 

    try{ 
    if(userid.length()==0) 
    return 0; 
    else{ 
    // 定义用户对象,设置其用户名和密码 
    User o_user = new User(); 
    o_user.setUserId(userid); 
    // 判断是否存在此用户信息,如果存在此用户则返回true 
    if(o_user.getUser()) 
    return o_user.getUserType(); 

    }catch(Exception e){ 
    e.printStackTrace(); 

    return 0; 

    %> 
    <% 
    IMG_SITE = "/servlet/Information.ReadImage?ImgId="; 
    %>
      

  3.   

    错误信息中提到的InfoComm.jsp文件中的问题语句:User cannot be resolved to a type中的User类的源文件User.java: //系统用户类 
    package Information; import java.util.*; 
    import java.io.*; 
    import java.sql.*; 
    import java.text.*; 
    import comm.*; 
    public class User { 
    private String UserId; // 用户名 
    private String EmplName; // 员工姓名 
    private String PassWord; // 密码 
    private int UserType; // 用户类型;1-经理;2- 管理员 StringOper so = new StringOper(); // 获得一个用户的信息,如果存在此用户返回true,否则false 
        public boolean getUser()throws Exception 
        { 
            int conditionNo = 0; 
            DBOper o_DBOper = new DBOper(); 
            ResultSet rs = null; String sql = "Select * from Users"; 
    String condition = " where "; 
    // 设置查询条件 
    if(UserId != null){ 
                condition += "UserId='"+UserId+"'"; 
                conditionNo++; 
            } 
            if(PassWord != null) 
            { 
                if(conditionNo > 0) 
                { 
                    condition += " and"; 
                } 
                condition += " PassWord='"+PassWord+"'"; 
                conditionNo++; 
            } 
    if(conditionNo > 0) 
            { 
                sql += condition; 
            } 
    System.out.println(sql); 
            try 
            { 
    // 执行查询操作 
                rs = o_DBOper.getResultSet(sql); 
                if(rs.next()) 
                { 
    setUserId(so.ReplaceNull(rs.getString("UserId"))); 
    setEmplName(so.ReplaceNull(rs.getString("EmplName"))); 
    setPassWord(so.ReplaceNull(rs.getString("PassWord"))); 
    setUserType(rs.getInt("UserType")); 
                    return true; 
                } 
            } 
            catch(Exception e) 
            { 
                throw new Exception(e.getMessage()); 
            } 
        finally 
        { 
                try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());} 
        } 
            return false; 
        } // 根据查询条件获得多个用户信息 
    public Vector getMoreUser() throws Exception 
        { 
            Vector v_User = new Vector(); 
            int conditionNo = 0;         DBOper o_DBOper = new DBOper(); 
            ResultSet rs = null;         String sql = "Select * from Users"; 
            String condition = " where "; 
            try 
            { 
                if(UserId != null) 
                { 
                    condition += " UserId='"+UserId+"'"; 
                    conditionNo++; 
                } 
                if(EmplName != null) 
                { 
                    if(conditionNo > 0) 
                    { 
                        condition += " and "; 
                    } 
                    condition += " EmplName='"+EmplName+"'"; 
                    conditionNo++; 
                } 
    if(UserType != 0) 
                { 
                    if(conditionNo > 0) 
                    { 
                        condition += " and "; 
                    } 
                    condition += " UserType="+UserType; 
                    conditionNo++; 
                } 
                if(conditionNo > 0) 
                { 
                    sql += condition; 
                } 
                sql += " order by UserId desc";             rs = o_DBOper.getResultSet(sql); 
    //System.out.println(sql); 
    while(rs.next()) 
                { 
                    User o_User2 = new User(); 
    o_User2.setUserId(so.ReplaceNull(rs.getString("UserId"))); 
    o_User2.setEmplName(so.ReplaceNull(rs.getString("EmplName"))); 
    o_User2.setPassWord(so.ReplaceNull(rs.getString("PassWord"))); 
    o_User2.setUserType(rs.getInt("UserType")); 
                    v_User.add(o_User2); 
                } 
            } 
            catch(Exception e) 
            { 
                throw new Exception(e.getMessage()); 
            } 
        finally 
        { 
                try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());} 
        } 
            return v_User; 
        } 
    //删除用户信息,条件为指定用户名 
    public void DeleteUser(String UserId) throws Exception 
        { 
            DBOper o_DBOper = new DBOper(); 
    ResultSet rs = null;         String sql_dlt = "delete from Users where UserId ='" + UserId + "'"; 
            try 
            { 
                o_DBOper.getResultSet(sql_dlt); 
            } 
            catch(Exception e) 
            { 
                throw new Exception(e.getMessage()); 
            } 
        finally 
        { 
                try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());} 
        } 
        } 
    //插入用户,密码缺省为6个1 
    public void CreateUser() throws Exception 
        { 
            DBOper o_DBOper = new DBOper(); 
            ResultSet rs = null;         String sql = "Insert into Users(UserId,EmplName,UserType,PassWord) "; 
    sql =sql+"values('"+UserId+"','"+EmplName+"',"+UserType+",'111111')"; 
    //System.out.println("INSERT SQL:"+sql); 
            try 
            { 
                o_DBOper.getResultSet(sql); 
            } 
            catch(Exception e) 
            { 
                throw new Exception(e.getMessage()); 
            } 
        finally 
        { 
                try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());} 
        } 
        } 
    // 更新用户信息,用于管理员更改用户信息,不更改密码 
    public void UpdateUser() throws Exception 
        { 
            DBOper o_DBOper = new DBOper(); 
            ResultSet rs = null;         String sql = "Update Users set EmplName='"+EmplName+"',UserType="+UserType; 
    sql = sql+" where UserId='"+UserId+"'"; 
    // System.out.println("UPDATE SQL :"+sql); 
            try 
            { 
                o_DBOper.getResultSet(sql); 
            } 
            catch(Exception e) 
            { 
                throw new Exception(e.getMessage()); 
            } 
        finally 
        { 
                try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());} 
        } 
        } 
    // 用户更改自己密码和管理员密码重置为六个1 
    public void UpdatePassWord() throws Exception 
        { 
            DBOper o_DBOper = new DBOper(); 
            ResultSet rs = null;         String sql = "Update Users set PassWord='"+PassWord+"' where UserId='"+UserId+"'"; 
            try 
            { 
                o_DBOper.getResultSet(sql); 
            } 
            catch(Exception e) 
            { 
                throw new Exception(e.getMessage()); 
            } 
        finally 
        { 
                try {o_DBOper.close();} catch (Exception e) { System.out.print(e.toString());} 
        } 
        } 
    // 设置、获得用户的信息 
    public void setUserId(String UserId){ 
            this.UserId = UserId; 
        } 
        public String getUserId(){ 
            return this.UserId; 
        } 
    public void setEmplName(String EmplName){ 
            this.EmplName = EmplName; 
        } 
        public String getEmplName(){ 
            return this.EmplName; 
        } 
    public void setPassWord(String PassWord){ 
            this.PassWord = PassWord; 
        } 
        public String getPassWord(){ 
            return this.PassWord; 
        } public void setUserType(int UserType){ 
            this.UserType = UserType; 
        } 
        public int getUserType(){ 
            return this.UserType; 
        } 

    谁知道是哪个地方有问题吗???????? 
      

  4.   

    系统找不到类的提示你的WEB-INF/classes文件夹下所有子文件夹都有没有.class文件啊,好像是你的工程没有对java源码进行build导致的,没有生成相关调用类的.class。你用Eclipse看看吧,构建一下