什么时候会使一个javaBean的实例=null??急救啊!

lanziman lanziman 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
//以下是.jsp里的
<%@page contentType="text/html;charset=GBK"%>
<jsp:useBean id="RW" class="test" />

<%=RW.read("o:\\test.txt")
%>
<%=RW.write("o:\\test1.txt")
%>

***************************************************************************************
//这个是我设计的javaBean
import java.io.*;
import java.lang.*;
public class Test{
private String readfile;
private String writefile;
public void read(String filename) throws IOException
{
File objFile;
FileReader objFileReader;
char []chrBuffer=new char[20];
int intLength ;
try{
objFile = new File(filename);
if ( objFile.exists() ){
objFileReader = new FileReader(objFile);
while((intLength =objFileReader.read(chrBuffer)) != -1){
System.out.println(chrBuffer);
}
objFileReader.close();
}
}catch(IOException e){
}
}
public void write(String filename)
{
try
{
PrintWriter pw = new PrintWriter(new FileOutputStream(filename));
String str = new String ("lanziman!");
pw.println(str);
pw.close();
}catch(FileNotFoundException e)
{
}

}

}

*********************************************************************************
//报的错误以下:
Generated servlet error:
[javac] Compiling 1 source file

D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myjsp\org\apache\jsp\_1_jsp.java:44: cannot resolve symbol
symbol : class test
location: class org.apache.jsp._1_jsp
test RW = null; ^

An error occurred at line: 2 in the jsp file: /1.jsp

Generated servlet error:
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myjsp\org\apache\jsp\_1_jsp.java:46: cannot resolve symbol
symbol : class test
location: class org.apache.jsp._1_jsp
RW = (test) _jspx_page_context.getAttribute("RW", PageContext.REQUEST_SCOPE);^

An error occurred at line: 2 in the jsp file: /1.jsp

Generated servlet error:
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myjsp\org\apache\jsp\_1_jsp.java:48: cannot resolve symbol
symbol : class test
location: class org.apache.jsp._1_jsp
RW = new test();
^
3 errors

*************************************************************************************

一个javaBean不是在用<jsp:useBean ……>
的时候就实例化了吗?为什么还有“test RW = null”??
...全文
评论 4
收藏 已收藏
分享
返回顶部
lanziman
Web 开发 81,107 成员 341,720 内容