请教 class的问题

iwantin 2004-09-21 01:58:35
我自己写了一个class,然后在jsp中调用,结果报错,错误如下:

Generated servlet error:
bad class file: D:\Tomcat\shared\classes\shecasafeapi\ReadConfInfo.class
class file contains wrong class: ReadConfInfo
Please remove or make sure it appears in the correct subdirectory of the classpath.


我得class的内容如下:

import java.io.*;
public class ReadConfInfo
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}

private String filePath;
private BufferedReader file;
public void setFilePath(String Path)
{
filePath = filePath;
}

public String getValue(String strTitle)
{
String strLine;
String strValue = null;
String strTmp;
char FirstChar;
int nIndex;
try
{
file = new BufferedReader(new FileReader(filePath));
}
catch (IOException e)
{
System.out.println("读文件错误");
return null;
}

try
{
while( (strLine = (file.readLine()).trim() )!=null)
{
if ((strLine.length()) != 0)
{

FirstChar = strLine.charAt(0);
if ( (FirstChar != '`') && (FirstChar != '#') && (FirstChar != '['))
{
strTmp = strTitle;
nIndex = strLine.indexOf(strTmp);

}
}
}
}
catch(IOException e)
{
return null;
}

return strValue;


}

}
...全文
86 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
iwantin 2004-09-21
我把class 放在了shecasafeapi下面,然后,调用的页面如下:

<%@ page import="shecasafeapi.*" %>
<%@ page import="java.util.*"%>
<%@ page contentType="text/html; charset=gb2312"%>

<%

shecasafeapi.ReadConfInfo rf = new shecasafeapi.ReadConfInfo();


%>

错误如下:

D:\Tomcat\work\Catalina\localhost\_\org\apache\jsp\test\testfile_jsp.java:50: cannot access shecasafeapi.ReadConfInfo



An error occurred at line: 5 in the jsp file: /test/testfile.jsp

Generated servlet error:
bad class file: D:\Tomcat\shared\classes\shecasafeapi\ReadConfInfo.class
class file contains wrong class: ReadConfInfo
Please remove or make sure it appears in the correct subdirectory of the classpath.
shecasafeapi.ReadConfInfo rf = new shecasafeapi.ReadConfInfo();
回复
stonecsdn 2004-09-21
ReadConfInfo没有包名,应该放在\shared\classes\下面或者web-inf/classes下面,不过最好有一个包名,这样就可以建立对应的目录
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-09-21 01:58
社区公告
暂无公告