码迷,mamicode.com
首页 > 其他好文 > 详细

Struts学习之动态表单

时间:2015-04-25 00:07:30      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:

1、与普通表单不同之处之基类为

org.apache.struts.action.DynaActionForm

2、与普通表单不同之处之struts-config.xml

  <form-bean name="userForm" type="org.apache.struts.action.DynaActionForm" >
        <!--该表单的属性需要配置如下-->
        <form-property name="name" type="java.lang.String"/>
        <form-property name="passwd" type="java.lang.String"/>
        <form-property name="email" type="java.lang.String"/>
    </form-bean>

3、访问表单数据不同之处之Action

public ActionForward register(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        DynaActionForm userForm = (DynaActionForm) form;// TODO Auto-generated method stub
        //从动态表单中取出数据
        String name = userForm.getString("name");
        String password = userForm.getString("passwd");
        String email = userForm.getString("email");
        
        System.out.println(name + ":" + password + ":" + email);
        
        return mapping.findForward("ok");
    }

 

Struts学习之动态表单

标签:

原文地址:http://www.cnblogs.com/jiqiwoniu/p/4454934.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!