网站大量收购独家精品文档,联系QQ:2885784924

第五讲 struts详解1.ppt

  1. 1、本文档共19页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第六讲 Struts详解 ActionServlet类的作用 主要功能 将请求的URI映射到一个相应的Action类 通过struts-config.xml指定ActionForm,获得表单数据填充FormBean 调用Action类的execute方法 ActionServlet类的作用 主要方法 process() InitApplication() InitMapping() InitDigester() InitOther() 增加和删除AciontForm beans,ActionForward和ActionMapping的方法 ActionServlet类的作用 process()方法的执行过程 request=processMultipart(request) String path=processPath() porcessLocale(request,response) processContent(request,response) processNoCache(request,response) processMapping(request,response) processActionForm(reqest,response) processPopulate(request,response,form,mapping) processActionCreate() processActionPerform() processActionFoward() ActionServlet类的作用 process()方法执行过程总结 从URI路径确定ActionMapping 处理ActionForm,如果没有就新创建一个,之后使用 将浏览器的表单字段值填入ActionForm中 判断是否执行ActionForm的validate()方法 处理Action 执行Action的execute()方法,并接收ActionForward 处理ActionForward Action类的作用 主要工作 验证使用者的进程状态、 进一步验证窗体对象的信息 更新应用程序中对象的状态 处理客户段的请求 返回ActionForward给ActionServlet转发给下一个视图 ActionMessages和ActionMessage struts1.1中用ActionErrors报告错误,用ActionMessages提供信息。 在struts1.2中使用ActionMessages提供信息和错误,不赞成使用ActionError struts1.3中已经没有ActionError类了。 ActionMessages和ActionMessage ActionMessages是消息容器 ActionMessage是消息对象 ActionMessage通过资源文件的主键查询内容 如果视图中用如下标记:html:errors property=“usename”/ 在资源文件中添加如下文字: username_wrong=your username wrong!~ 使用关键代码如下: ActionMessages errors = new ActionMessages(); if(…){ errors.add(“username”,new ActionMessage(“username_wrong”); this.saveErrors(request,errors); return mapping.getInputForward(); } ActionForward 功能 转发对象,转发目标通过定义字符串来区分,转发目标可以是Servlet,jsp或Action 类型 局部ActionForwar和全局ActionForwar 两种创建方法 1.struts-config.xml中定义方法 2.new ActionForward方法 ActionForward myforward=new ActionForward; myforward.setName=“suesses”); myforward.setPath(“/form/my.jsp”); return myforward; ForwardAction 功能:实现页面或Web组件的跳转,类似于jsp:forward标签。 使用场所:视图中需要使用超连接a 创建方法1:Use existing Action class,并设置Parameter为要连接的页面或组件。 创建方法2:Action type选择Forward,并设置Forward path为要连接的页面或组件。 请求代码: html:link action=“/xxx.do”toForwar

文档评论(0)

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档