工作小总结

spring mvc 接收页面表单List 怎么处理

需求:我们可以看出一个商品对应多个SKU 一个SKU又有两种不同的优惠方案,即优惠价格和折扣率。form 一次性提交,springmvc怎么处理呢?根据页面,我们可以封装一个goods对象,goods对象里面有个SKU的集合。如下图:public class Goods implements Serializable{int i

需求:

958a6356cf629bab4da3dcb796b0ba9b.png

我们可以看出一个商品对应多个SKU 一个SKU又有两种不同的优惠方案,即优惠价格和折扣率。

form 一次性提交,spring mvc怎么处理呢?

根据页面,我们可以封装一个goods对象,goods对象里面有个SKU的集合。如下图:

93d2a5e189ecbdb4dee80586d6d1b80a.png

public class Goods implements Serializable{
	int id;		//
	List<SKU> skuList;

SKU对象:

e957d130e68f9901219eec68aebcb676.png

public class SKU implements Serializable{
	int id;
	String  name;
	int goodsId;		//商品id
	BigDecimal price;		//优化价格
	double DiscountRate 	;///折扣率	

jsp页面:

86fc3da2bc8e29ec3683f58dcc579075.png

804054fb677f60ad2c0e8bdbdd5450e5.png


具体如下:

使用到了rowspan进行行合并的。

<form  action="/saveByForm" method="post">
	<table width="100%" border="1">
  <tr>
    <th>商品idth</th>
    <th>商品规格</th>
    <th>优化政策</th>
  </tr>
  <tr>
    <td rows

原创不易,完成人机校验,阅读全文

相关推荐