ITeye博客

2009 年文章归档

共 9 篇文章

(9)LookupDispatchAction

1. 创建资源信息文件,内容如下 button.save=save button.checkout=checkout index.username=UserName: 2. 创建页面 <html:form action="lookup.do"> <bean:message key="index.username"/><html:text property="name"></html:text> <html:submit property="action"> <bean:message key="button.save"/> </html:submit> <html:submit proper…

2009-07-09 17:10 · Struts1

(8)ForwardAction

1. 创建页面 <html:link page= "/action.do" >success</html:link> 2. 配置ForwardActions <action path= "/action" type= "org.apache.struts.actions.ForwardAction" parameter= "/success.jsp" > </action>

2009-07-09 17:04 · Struts1

(7)扩展RequestProcessor类

1. 创建一个类继承RequestProcessor并且重写process()方法 public class MyRequestProcessor extends RequestProcessor { @Override public void process(HttpServletRequest arg0, HttpServletResponse arg1) throws IOException, ServletException { System.out.println("调用Action之前的工作在这里完成"); super.process(arg0, arg1); } } 2. 在s…

2009-07-09 17:02 · Struts1

(6)将实体对象作为DynaActionForm的属性

1. 新建实体对象Student public class Student { private String userName; private int age; private String address; public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public int getAge() { return age; } public void setAge(int age) { this.ag…

2009-07-09 16:56 · Struts1

(5)将实体对象作为ActionForm的属性

1. 新建实体对象Student public class Student { private String userName; private int age; private String address; public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public int getAge() { return age; } public void setAge(int age) { this.ag…

2009-07-09 16:52 · Struts1

(4)DynaActionForm

1.创建页面文件 <body> <form action="regist.do" method="get"> name:<input type="text" name="userName"> age :<input type="text" name="age"> address:<input type="text" name="address"> <input type="submit" name="button1"> </form> </body> 2.在struts-config.xml文件中配置DynaActionForm <form-beans > <form-bean name="…

2009-07-08 15:01 · Struts1

(3)struts的错误提示

1. 在资源配置文件中添加错误信息键值对 error=InputError 2. 在Action中,如果出现错误,则按照以下方式存储错误信息 ActionMessages errors = new ActionMessages(); try{ r = c.add(Double.parseDouble(f.getFirst()),Double.parseDouble(f.getSecond())); }catch(Exception e){ errors.add("num",new ActionMessage("error")); this.saveErrors(request, errors…

2009-07-08 14:43 · Struts1

(2)DiapacthAction

DispatchAction 用于分发的Action,主要的好处是把一些功能类似的Action放到一个Action中,通过传入的不同参数来觉得执行哪个操作. 创建一个类继承DispacthAction,该类中包含多个除方法名称以外其他都和execute()方法一样的多个方法 public class OperateAction extends DispatchAction { public ActionForward add (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResp…

2009-07-08 14:25 · Struts1

(1)第一个struts应用

开发第一个简单的Struts应用 1. 为WEB工程添加Struts支持 2. 在工程的WEB-INF下添加Struts-config.xml配置文件 3. 在web.xml中配置struts的中央控制器ActionServlet <servlet> <servlet-name>ActionServlet</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <load-on-startup>0</load-on-startup> <init-param> <param-nam…

2009-07-08 13:51 · Struts1