日期:2014-05-18  浏览次数:20703 次

JSP JAVABEAN 的问题
JSP文件代码如下 <%@   page   contentType= "text/html;charset=GB2312 "%>
<html>
<head> <title> 读取文件 </title> </head>
<body   bgcolor= "white ">
<jsp:useBean   id= "file_reader "   class= "fileReader "   scope= "session "/>
<jsp:setProperty   name= "file_reader "   property= "fileName "   />

<%   if   (file_reader.getFileName()   !=   " ")   {   %>

文件[   ' <%   out.println(file_reader.getFileName());   %> ']内容   :   <br> <br>

<%   if   (file_reader.getContent()   !=   null)   {   %>

<Form>
<TEXTAREA   rows= <%=   file_reader.getRows()   %>   cols= <%=   file_reader.getColumns()   %>   id=textarea1   name=textarea1>

<%   out.println(file_reader.getContent());   %>

</TEXTAREA>
</Form>

<%   }   else   {   %>
<%   out.println(file_reader.getErrorMessage());   %>

<%   }   %>

<br> <br>

<%   file_reader.reset();   %>
<a   href= "fileReader.jsp "> 读取另外的文件 </a>


<%   }   else   {   %>

读取文件内容的例子。
<form   method=get>
输入文件名:   <input   type=text   name=fileName>
<input   type=submit   value= "读取文件内容 ">
</form>

<%   }   %>

</font>
</body>
</html>
错误代码如下
org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP:  

An   error   occurred   at   line:   5   in   the   jsp   file:   /test/fileReader.jsp
fileReader   cannot   be   resolved   to   a   type
2:   <html>
3:   <head> <title> 读取文件 </title> </head>
4:   <body   bgcolor= "white ">
5:   <jsp:useBean   id= "file_reader "   class= "fileReader "   scope= "session "/>
6:   <jsp:setProperty   name= "file_reader "   property= "fileName "   />
7:  
8:   <%   if   (file_reader.getFileName()   !=   " ")   {   %>


An   error   occurred   at   line:   5   in   the   jsp   file:   /test/fileReader.jsp
fileReader   cannot   be   resolved   to   a   type
2:   <html>
3:   <head> <title> 读取文件 </title> </head>
4:   <body   bgcolor= "white ">
5:   <jsp:useBean   id= "file_reader "   class= "fileReader "   scope= "session "/>
6:   <jsp:setProperty   name= "file_reader "   property= "fileName "   />
7:  
8:   <%   if   (file_reader.getFileName()   !=   " ")