什么时候会使一个javaBean的实例=null??急救啊!
//以下是.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”??
<%@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”??
...全文
相关推荐
JAVABEAN方法实例
= null && !string2.isEmpty() && string1 != null && !
首字母大写的json串转为javabean实例
在Java编程中,将JSON字符串转换为JavaBean实例是一个常见的任务,特别是在处理Web服务或API交互时。
jsp计数器——使用javabean、session实现!
**在JSP中使用JavaBean**:通过`<jsp:useBean>`指令在JSP页面中声明并实例化JavaBean,设置存活周期为`application`,确保在整个应用程序生命周期内只存在一个实例
实验四 JavaBean及Servlet使用
登录表单如下:```html<!
java反射实现javabean转json实例代码.docx
通常会包含创建JavaBean实例的方法及调用`ObjectToJson`类的方法进行转换的逻辑。


Web 开发
