【6】Struts2的复杂类型数据的封装
来源:互联网 发布:gta5麦克捏脸数据 编辑:程序博客网 时间:2024/06/06 06:56
1、List集合的数据的封装
页面:
<h1>批量插入商品</h1>
<form action="${ pageContext.request.contextPath }/product1Action.action"method="post">
商品名称:<input type="text" name="list[0].name"><br/>
商品价格:<input type="text" name="list[0].price"><br/>
商品名称:<input type="text" name="list[1].name"><br/>
商品价格:<input type="text" name="list[1].price"><br/>
商品名称:<input type="text" name="list[2].name"><br/>
商品价格:<input type="text" name="list[2].price"><br/>
<inputtype="submit"value="批量导入">
</form>
Action:
/**
* Struts2复杂数据类型的封装:封装到List集合中
*
*/
public class Product1Action extends ActionSupport{
private List<Product> list;
public List<Product> getList() {
returnlist;
}
publicvoid setList(List<Product> list) {
this.list = list;
}
@Override
public String execute() throws Exception {
for (Product product : list) {
System.out.println(product);
}
return NONE;
}
}
2、Map集合的数据的封装
页面
<h1>批量插入商品:封装到Map集合</h1>
<form action="${ pageContext.request.contextPath }/product2Action.action"method="post">
商品名称:<input type="text" name="map['one'].name"><br/>
商品价格:<input type="text" name="map['one'].price"><br/>
商品名称:<input type="text" name="map['two'].name"><br/>
商品价格:<input type="text" name="map['two'].price"><br/>
商品名称:<input type="text" name="map['three'].name"><br/>
商品价格:<input type="text" name="map['three'].price"><br/>
<inputtype="submit"value="批量导入">
</form>
Action:
/**
* Struts2的复杂数据的封装:Map集合的封装
* @author lwt
*
*/
public class Product2Action extends ActionSupport{
private Map<String,Product> map;
public Map<String, Product> getMap() {
return map;
}
public void setMap(Map<String, Product> map) {
this.map = map;
}
@Override
public String execute() throws Exception {
for (String key : map.keySet()) {
Product product = map.get(key);
System.out.println(key+" "+product);
}
return NONE;
}
}
- 【6】Struts2的复杂类型数据的封装
- Struts2数据的封装
- Struts2封装数据的操作
- 封装集合类型的数据
- 使用 SharedPreferences 存取复杂类型的数据
- Activity传递复杂类型的数据
- 使用SharedPreferences保存复杂类型的数据
- 使用Struts2的iterator标签遍历复杂的Map类型
- 使用Struts2的iterator标签遍历复杂的Map类型
- 【5】Struts2的数据的封装
- 《深入浅出struts2》--第七章,类型转换-支持复杂的对象
- Struts2的知识整理总结(三)—— 数据封装和类型转换
- struts2中基于表单数据的封装
- ssh学习:struts2的数据封装
- Struts2 封装集合或Map的数据
- struts2的封装数据核心机制
- 复杂的变量类型
- 复杂的变量类型
- Kafka中gradle.properties源码
- 从内核文件系统看文件读写过程
- 4-1 Shortest Path [3]
- 学Java遇到的问题
- electron开发记录(一):安装nodejs并运行demo
- 【6】Struts2的复杂类型数据的封装
- 机器学习算法分类
- 4-2 Shortest Path [4]
- ABAP数据库操作之操作语句Insert
- hotplug_uevent机制_修改mdev配置支持U盘自动挂载学习笔记
- 摄像机标定和立体标定
- idea 搭建 springMVC+mybatis+maven 项目(二)
- 【7】Struts2中结果页面的配置
- python的getattr和setattr