帮我看一段代码,在JAVABEAN中读文件,结果总出错
package readtext;
import java.awt.*;
import javax.swing.JPanel;
import java.io.*;
public class readfile extends JPanel {
private BorderLayout borderLayout1 = new BorderLayout();
String str = "";
String content = "";
private void setStr(){
str = content;
}
private String getStr(){
return str;
}
public readfile() {
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setLayout(borderLayout1);
File readFile = null;
try
{
readFile = new File("D:\\SoftWare\\init.ini");
FileInputStream is = new FileInputStream(readFile);
int size = is.available();
byte[] bytes = new byte[size];
is.read(bytes);
is.close();
content = new String(bytes);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
JSP中是这样的:
...................
<jsp:useBean id="readfile" scope="session" class="readtext.readfile" />
<jsp:setProperty name="readfile" property="str" />
<jsp:getProperty name="readfile" property="str" />
编译的结果是这样的:
"JspRead.jsp": org.apache.jasper.JasperException: Cannot find any information on property 'str' in a bean of type 'readtext.readfile'