Struts1配置实例.docx

上传人:博****1 文档编号:542546975 上传时间:2023-04-22 格式:DOCX 页数:28 大小:264.14KB
返回 下载 相关 举报
Struts1配置实例.docx_第1页
第1页 / 共28页
Struts1配置实例.docx_第2页
第2页 / 共28页
Struts1配置实例.docx_第3页
第3页 / 共28页
Struts1配置实例.docx_第4页
第4页 / 共28页
Struts1配置实例.docx_第5页
第5页 / 共28页
点击查看更多>>
资源描述

《Struts1配置实例.docx》由会员分享,可在线阅读,更多相关《Struts1配置实例.docx(28页珍藏版)》请在金锄头文库上搜索。

1、Struts1配置实例1 struts1之初来乍到Step1 使用myeclipse向导引入strut1.2web.xml文件里面自动生成代码: action org.apache.struts.action.ActionServlet config /WEB-INF/struts-config.xml debug 3 detail 3 0 action *.do index.jsp Step2 配置文件struts-config.xml !- - !- -对应的逻辑图:Step3 包com.struts.form的HelloForm.java/* * Generated by MyEclip

2、se Struts * Template path: templates/java/JavaClass.vtl */package com.struts.form;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;/* * MyEclipse Struts * Creation date:

3、03-15-2014 * * XDoclet definition: * struts.form name=helloForm */public class HelloForm extends ActionForm /* * Generated fields */* name property */private String name;/* * Generated Methods */* * Method validate * param mapping * param request * return ActionErrors */public ActionErrors validate(

4、ActionMapping mapping,HttpServletRequest request) / TODO Auto-generated method stubreturn null;/* * Method reset * param mapping * param request */public void reset(ActionMapping mapping, HttpServletRequest request) / TODO Auto-generated method stub/* * Returns the name. * return String */public Str

5、ing getName() return name;/* * Set the name. * param name The name to set */public void setName(String name) this.name = name;包com.struts.action的HelloAction.java/* * Generated by MyEclipse Struts * Template path: templates/java/JavaClass.vtl */package com.struts.action;import javax.servlet.http.Http

6、ServletRequest;import javax.servlet.http.HttpServletResponse;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.struts.form.HelloForm;/* * MyEclipse Struts * Creation

7、 date: 03-15-2014 * * 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 ActionFo

8、rward */public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) HelloForm helloForm = (HelloForm) form;/ TODO Auto-generated method stubif(helloForm.getName()=null|helloForm.getName().trim().length()=0)/返回输入页面 就是/form/hello.jsp,配置在struts-config.xml中return mapping.getInputForward();return mapping.findForward(success);Step4 包/itatis1.1/WebRoot/form下的hello.jsp%taglib uri=http:/strut

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号