import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yourcompany.struts.form.LoginForm;
public class LoginAction extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
{
ActionErrors errors=new ActionErrors();
LoginForm loginForm = (LoginForm) form;
String username=loginForm.getName();
if(username.equals("hello"))
{
return mapping.findForward("success");
}
else
{
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("error.msg"));
saveErrors(request,errors);
return (new ActionForward(mapping.getInput()));
}
}
}
--------------------------------------
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("error.msg"));
saveErrors(request,errors);
这两句始终出错.错误信息是The field ActionErrors.GLOBAL_ERROR is deprecated;ActionError cannot be resolved to a type;The method saveErrors(HttpServletRequest, ActionErrors) from the type Action is deprecated请问一下,是什么错误啊?该怎么解决啊?谢谢各位大哥了.谢谢
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yourcompany.struts.form.LoginForm;
public class LoginAction extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
{
ActionErrors errors=new ActionErrors();
LoginForm loginForm = (LoginForm) form;
String username=loginForm.getName();
if(username.equals("hello"))
{
return mapping.findForward("success");
}
else
{
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("error.msg"));
saveErrors(request,errors);
return (new ActionForward(mapping.getInput()));
}
}
}
--------------------------------------
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("error.msg"));
saveErrors(request,errors);
这两句始终出错.错误信息是The field ActionErrors.GLOBAL_ERROR is deprecated;ActionError cannot be resolved to a type;The method saveErrors(HttpServletRequest, ActionErrors) from the type Action is deprecated请问一下,是什么错误啊?该怎么解决啊?谢谢各位大哥了.谢谢
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
而且import org.apache.struts.action.ActionError;这个包导入后,这个包的提示为:The type ActionError is deprecated
errors.add("error", new ActionMessage("error.msg"));
还是不行啊.
我是Struts1.2的