struts2 复杂参数封装
1.1.1 Struts2中封装复杂类型的数据:
封装到List集合:
页面:
商品名称:<input type="text" name="products[0].pname"/><br/>
商品价格:<input type="text" name="products[0].price"/><br/>
商品名称:<input type="text" name="products[1].pname"/><br/>
商品价格:<input type="text" name="products[1].price"/><br/>
商品名称:<input type="text" name="products[2].pname"/><br/>
商品价格:<input type="text" name="products[2].price"/><br/>
Action:
public class ProductAction1 extends ActionSupport{
private List<Product> products;
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
}
封装到Map集合
页面:
商品名称:<input type="text" name="map['one'].pname"/><br/>
商品价格:<input type="text" name="map['one'].price"/><br/>
商品名称:<input type="text" name="map['two'].pname"/><br/>
商品价格:<input type="text" name="map['two'].price"/><br/>
商品名称:<input type="text" name="map['three'].pname"/><br/>
商品价格:<input type="text" name="map['three'].price"/><br/>
Action:
public class ProductAction2 extends ActionSupport{
private Map<String,Product> map;
public Map<String, Product> getMap() {
return map;
}
public void setMap(Map<String, Product> map) {
this.map = map;
}
}
struts2 复杂参数封装的更多相关文章
- (八)Struts2中的参数封装
一.静态参数封装 什么是静态参数? 静态参数就是硬编码的,不可随意改变. 例子: (1)我们首先创建一个Action类,里面有两个参数,用来封装请求参数 public class User exten ...
- struts2 二: 参数封装
封装请求正文到对象中(非常重要) 1.静态参数封装 在struts.xml配置文件中,给动作类注入值.调用的是setter方法. struts.xml的编写: <action name=&quo ...
- Struts2(二)之封装请求正文、数据类型转换、数据验证
一.封装请求正文到对象中(重点) 1.1.静态参数封装 在struts.xml文件中,给动作类注入值,使用的是setter方法 1.2.动态参数封装 通过用户表单封装请求正文参数 1.2.1.动作类作 ...
- Struts2获取参数的几种方式
Struts2由于是一个贴心的框架,所以获取参数这种体力活,就无需再通过原生的request来getParameter了,有如下几种方式进行获取 1.Action中属性驱动,必须提供与form表单na ...
- Struts 2.3.24源码解析+Struts2拦截参数,处理请求,返回到前台过程详析
Struts2官网:http://struts.apache.org/ 目前最新版本:Struts 2.3.24 Struts1已经完全被淘汰了,而Struts2是借鉴了webwork的设计理念而设计 ...
- Struts2接受参数的几种类型和接受复杂类型参数(list<String>和list<Object>)
Struts2接受参数的几种类型 大概有这几种类型: 1.使用Action的属性接受参数 在Action中加入成员变量,配置Getter和Setter方法,Getter而和Setter方法的名字和表单 ...
- 在jsp提交表单的参数封装到一个方法里
建议去看一下孤傲苍狼写的Servlet+JSP+JavaBean开发模式(http://www.cnblogs.com/xdp-gacl/p/3902537.html), 最好把他JavaWeb学习总 ...
- 通过反射将request中的参数封装到对象中
import java.beans.PropertyDescriptor; import java.lang.reflect.Method; import java.text.SimpleDateFo ...
- Spring MVC参数封装传递
在Spring MVC中,前端JSP页面可以传递 基本类型(int,String).实体类型.包装类型.数组类型.集合类型(List.map )等. 假如在传递的类型中有 Date类型的字段,需要在 ...
随机推荐
- jQuery EasyUI API 中文文档 - ComboGrid 组合表格
jQuery EasyUI API 中文文档 - ComboGrid 组合表格,需要的朋友可以参考下. 扩展自 $.fn.combo.defaults 和 $.fn.datagrid.defaults ...
- [Angularjs]表单验证
写在前面 在开发中提交表单,并对表单的值进行验证是非常常见的操作,angularjs对表单验证提供了非常好的支持. demo 表单 <form name="myform" n ...
- 【采集层】Kafka 与 Flume 如何选择--转自悟性的博文
[采集层]Kafka 与 Flume 如何选择 收藏 悟性 发表于 2年前 阅读 23167 收藏 16 点赞 4 评论 1 摘要: Kafka, Flume 采集层 主要可以使用Flume, Kaf ...
- Linux命令lsb_release:查看当前系统的发行版信息
Linux里的lsb_release命令用来查看当前系统的发行版信 息(prints certain LSB (Linux Standard Base) and Distribution inform ...
- jquery mobile常用的data-role类型 data-icon data-iconpos
文章链接: http://blog.csdn.net/cainiaoxiaozhou/article/details/48521241
- 使用vagrant部署开发环境
参考文章:http://blog.smdcn.net/article/1308.html 准备工作: 下载安装 VirtualBox :https://www.virtualbox.org/ 下载安装 ...
- dijkstra算法求最短路
艾兹格·W·迪科斯彻 (Edsger Wybe Dijkstra,1930年5月11日~2002年8月6日)荷兰人. 计算机科学家,毕业就职于荷兰Leiden大学,早年钻研物理及数学,而后转为计算学. ...
- Java字节流:BufferedInputStream BufferedOutputStream
-----------------------------------------------------------------------------------BufferedInputStre ...
- JavaScript模板引擎实现数据交互
经过1年的磨练,近期终于稍微明白到,前端是怎么做到企业要求的:数据交互. 1,ajax+json这个是必须学的,但没问题,我们可以通过这个博客来慢慢了解怎么回事? 2,可以通过JS框架和JS模板来实现 ...
- Backbone事件模块源码分析
事件模块Backbone.Events在Backbone中占有十分重要的位置,其他模块Model,Collection,View所有事件模块都依赖它.通过继承Events的方法来实现事件的管理,可以说 ...