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

导入类的问题,怎么也想不明白
工作目录为webapps\zz\
自己写的类password.class放在webapps\zz\WEB-INF\classes\zz下面
package   zz;

import   java.io.*;

public   class   password
{
private   String   filePath;
private   String   password;

public   password(String   filePath)   {
this.filePath   =   filePath;
}

public   String   getPassword()   {
try   {
FileInputStream   inputFile   =   new   FileInputStream(filePath);
ObjectInputStream   in   =   new   ObjectInputStream(inputFile);
password   =   (String)in.readObject();
in.close();
inputFile.close();
                }   catch(Exception   e)   {
e.printStackTrace();
                }
return   password;
}

public   void   setPassword(String   password)   {
try   {
FileOutputStream   outputFile   =   new   FileOutputStream(filePath);
ObjectOutputStream   out   =   new   ObjectOutputStream(outputFile);
out.writeObject(password);
out.flush();
out.close();
outputFile.close();
}   catch   (IOException   ioe)   {
ioe.printStackTrace();
}
}
}


JSP页面test.jsp放在webapps\zz\pages\11\下
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "zz.* "%>
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
</head>
<%
String   password   =   "111 ";
out.println(password);

password   pass   =   new   password( "psd.ini ");
//pass.setPassword(password);
%>
<body>
</body>
</html>

为什么运行时就出错,错误如下
org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP:  


An   error   occurred   at   line:   12   in   the   jsp   file:   /pages/11/test.jsp
password   cannot   be   resolved   to   a   type
9:   String   password   =   "111 ";
10:   out.println(password);
11:  
12:   password   pass   =   new   password( "psd.ini ");
13:   //pass.setPassword(password);
14:   %>
15:   <body>


An   error   occurred   at   line:   12   in   the   jsp   file:   /pages/11/test.jsp
password   cannot   be   resolved   to   a   type
9:   String   password   =   "111 ";
10:   out.printl