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

初学者,问一个奇怪的问题
现在写有两个类,代码如下
package   mycls;

import   javax.servlet.http.HttpServletRequest;
import   org.apache.struts.action.*;
import   org.apache.struts.action.ActionForm;

public   final   class   SubmitForm   extends   ActionForm
{
private   String   name=null;
private   String   password=null;

public   String   getName()
{
return(this.name);
}

public   String   getPassword()
{
return(this.password);
}

public   void   setName(   String   name   )
{
this.name   =   name;
}

public   void   getPassword(   String   pw   )
{
this.password   =   pw;
}

public   void   reset(   ActionMapping   mapping,   HttpServletRequest   request   )
{
this.name=null;
this.password=null;
}

public   ActionErrors   validate(   ActionMapping   mapping,   HttpServletRequest   request   )
{
ActionErrors   errors   =   new   ActionErrors();
return   errors;
}
};


package   mycls;

import   javax.servlet.RequestDispatcher;
import   javax.servlet.ServletException;
import   javax.servlet.http.HttpServletRequest;
import   javax.servlet.http.HttpSession;
import   javax.servlet.http.HttpServletResponse;

import   org.apache.struts.action.ActionForm;
import   org.apache.struts.action.*;
import   org.apache.struts.util.MessageResources;

public   final   class   SubmitAction   extends   Action
{
public   ActionForward   execute(
ActionMapping   mapping,
ActionForm   form,
HttpServletRequest   request,
HttpServletResponse   response
)throws   Exception
{
String   uName   =   (String)((SubmitForm)form).getName();
String   uPw   =   (String)((SubmitForm)form).getPassword();
if   (   uName!=uPw   )
{
return   (mapping.findForward( "FALSE "));
}
return   (mapping.findForward( "OK "));
}
};


两个.java文件都放在同一个文件夹mycls中,现在类SubmitForm可以成功编译,但是SubmitAction在编译时报错

SubmitAction.java:22:   找不到符号
符号:   类   SubmitForm
位置:   类   mycls.SubmitAction
                                String   uName   =   (String)((SubmitForm)form).getName();
                                                                                  ^
SubmitAction.java:23:   找不到符号
符号:   类   SubmitForm
位置:   类   mycls.SubmitAction
                                String   uPw   =   (String)((SubmitForm)form).getPassword