`
wangyanlong0107
  • 浏览: 481710 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

struts1 一次提交多个ActionForm

 
阅读更多

JSP中有两个actionform放在同一个form中,分别对应两个数据库表,现在用的是struts1,如何实现在同一个form中提交,交给后台的action处理?

 

struts1不支持一个页面多个actionform,想复用form就继承。 但是不能复用另外的actoin,只能用html写个表单提交到那个写好的action。

 

1) 
如果只提交一次form,然后调用对应的action,然后在action里面进一步把form中的值取出来,然后插入或者更新到两张数据库表中的话,可以采用下面的方式。 

复用已有的两个form bean,让其中的一个form bean继承自另一个form bean。比如: 

public class MyForm2 extends ActionForm{ 



public class MyForm1 extends MyForm2{ 



然后在struts-config.xml里面只配置MyForm1即可。 

<action-mappings> 
   <action path="/MyAction" type="MyAction" name="MyForm1" /> 
</action-mappings> 

public class MyAction extends Action { 
    public ActionForward execute( 
      ActionMapping mapping,ActionForm form, 
      HttpServletRequest request, HttpServletResponse response)    throws Exception { 
                 MyForm1 myForm = (MyForm1) form; 
            } 


最好还是单独定义一个form bean,里面包含所有的form项目,这样比较好理解,毕竟MyForm1和MyForm2没有继承关系。 

分享到:
评论

相关推荐

    一个Jsp两个ActionForm分别提交.rar

    一个Jsp两个ActionForm分别提交.rar一个Jsp两个ActionForm分别提交.rar一个Jsp两个ActionForm分别提交.rar一个Jsp两个ActionForm分别提交.rar一个Jsp两个ActionForm分别提交.rar

    struts1使用actionform实现表单验证

    struts1使用actionform实现表单验证,表单验证失败追加信息。

    struts 视频 struts视频 actionform

    struts 视频 struts视频 actionform

    Struts Hibernate Spring 集成开发宝典 actionform

    Struts Hibernate Spring 集成开发宝典 actionform 有研究或探讨或开源的请加群:37424970 或联系本人MSN或邮箱:zhuseahui@yahoo.com.cn

    Struts_学习笔记之ActionForm

    Struts_学习笔记之ActionForm,简单配置即可达到效果

    struts中静态ActionForm基本验证

    主要是actionForm的基本验证,重写validate方法,返回actionErrors,然后根据资源文件显示错误。...这是一个demo例子,直接导入eclispe中即可。 并且这部分内容会在相应的博客中介绍,稍后会更新博客。

    提交多行数据到Struts的ActionForm的List属性中

    NULL 博文链接:https://arang.iteye.com/blog/420546

    struts中配置动态ActionForm

    最近自学java中的框架-struts写了一些小例子,这都是很经典的程序,如果大家瞧得起要下载去看看,顺便给俺找找不足的地方。我的qq 821865130 email qingtian_hechen@163.com 希望大家能多多给我帮助。在此谢谢各位!...

    struts中ActionForm的validate方法使用小得

    struts提供了标签来显示整个ActionErrors的错误信息。但要在struts-config.xml中设置&lt;action ...

    struts2配置详解

    2、Struts1 中每个 HTML 表单都对应一个 ActionForm 实例. Struts2 中, HTML 表单将被直接映射到一个 POJO. 3、Struts1 的验证逻辑编写在 ActionForm 中; Struts2 中的验证逻辑编写在 Action 中. 4、Struts1 中, ...

    Struts中不同的Action和ActionForm组合.rar

    Struts中不同的Action和ActionForm组合.rar

    Struts高级开发_动态ActionForm.avi

    该avi很好的讲解动态actionForm,通过练习可以理解它的运行过程

    Struts中处理表单跨页提交源代码

    这时,既可以为每一个表单创建一个ActionForm,也可以只创建一个ActionForm,它和多个表单对应。这里讨论如何用一个ActionForm对应表单。 程序完整解释可以到我的空间查看: ...

    struts1架构登录代码

    使用myeclipse的struts架构登录 登录例示代码actionForm和action

    Struts_开发的最佳实践

    要验证请求数据,ActionForm 的 validate() 方法必须给出一个特定于该情况的实现。ActionForm 作为运载工具,向 Action 类提供请求数据。一个 JSP 对象与各自的 ActionForm 对象相结合,构成应用程序的 View 层。在...

    struts1 用户登录(包含验证)

    使用struts1框架实现用户登录,那么就需要新建两个类,比如:LoginForm、LoginAction继承ActionForm、Action,配置struts-config.xml配置文件

    Struts2教程

    Struts2 Struts2 Struts2 教程 1 1 1 :第一个 Struts2 Struts2 Struts2 程序 在本系列教程中我们将学习到 Struts2 的各种技术。在本教程中使用的工具和程序库的版本 如下: 开发工具: MyEclipse6 Web 服务器: ...

    struts1 tutorial

    6.Struts: Introducing the ActionForm 7.A better way to seperate Book and BookForm 8.Handling Invalid Entries 9.Recapitualation: Where we are 10.Using Logic 11.Templates 12.FAQ 13.Beans ...

    STRUTS ActionForm乱码,servlet全局过滤器转义编码。

    STRUTS ActionForm乱码,servlet全局过滤器转义编码

    struts的教程.doc

    目录 概述 4 Framework概念 4 Struts的概念和体系结构 5 Struts的与Web App的关系 5 ...Struts的体系结构 5 ...Struts的基本组件包 6 ...Struts framework的工作原理和组件 7 ...分离Book和BookForm的一个好方法 51

Global site tag (gtag.js) - Google Analytics