struts2 复杂参数封装
2016-07-13 22:45
501 查看
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;
}
}
相关文章推荐
- java_reflect_03
- Eclipse中android插件的安装
- 怎样在java虚拟机中理解Java并发
- Spring入门篇学习笔记(2)
- JAVA回调机制
- Struts2工作原理及流程
- java ssh 框架下 利用junit4 spring-test进行单元测试
- java基础总结
- [转]Eclipse Java注释模板设置详解
- java_annotation_02
- java 事件处理的几种写法
- 第二章 怎样把android studio快捷键设置与eclipse一样
- java获取中国时间代码(适用全球任意机器)
- Java-1.5新特性之注解
- Java 读取excel文件 兼容97-2013
- JAVA设计模式--代理模式(动态)(二)
- Java中的Set集合
- eclipse中代码注释
- struts2 如何实现mvc 的?
- 在写junit test 的时候出现的java.lang.UnsupportedClassVersionError问题