新学习用myeclipse开发struts
第一个就把我郁闷了。。。 HelloAction.java
package com.yourcompany.struts.action;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.MessageResources;
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.HelloForm;
/**
* MyEclipse Struts
* Creation date: 09-17-2007
*
* XDoclet definition:
* @struts.action path="/hello" name="helloForm" input="/form/hello.jsp" scope="request" validate="true"
*/
public class HelloAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception {
MessageResources messages=getResources(request);
ActionMessages errors=new ActionMessages();
String userName=(String)((HelloForm)form).getUserName();
String badUserName="Monster";
if(userName.equalsIgnoreCase(badUserName))
{
errors.add("username",new ActionMessage("hello.dont.talk.to.monster,badUserName"));
saveErrors(request,errors);
return(new ActionForward(mapping.getInput()));
}
PersonBean pb=new PersonBean();
pb.setUserName(userName);
pb.saveToPersistentStore();
request.setAttribute(Constants.PERSON_KEY, pb);
request.removeAttribute(mapping.getAttribute());
return(mapping.findForward(SayHello));
}
}
以上代码又颜色的myeclipse都说cannot be resolved,我是一点点按书上来写的,请问下是什么问题,还需要导入什么吗?
还有就是怎么创建模型组件PersonBean.java...我找了半天没找到地方。。。我用的是myeclipse6.0 struts1.1(孙姐姐那本)