看看大家在struts2中是怎么从jsp传list到后台的
先说下我的方法,也是捣鼓了一下:
action中:private List<Kpi> kpiLists2 ;
jsp中: <%int i= -1; %>
<s:iterator value="%{kpiLists}" var="kpi">
<%i++;%>
<tr>
<td><input name="kpiLists2[<%= i%>].keywords" value="${kpi.keywords }"/></td>
<td><input name="kpiLists2[<%= i%>].price" value="${kpi.price }"/></td>
<td><input name="kpiLists2[<%= i%>].showTimes" value="${kpi.showTimes }"/></td>
<td><input name="kpiLists2[<%= i%>].clickTimes" value="${kpi.clickTimes }"/></td>
<td><input name="kpiLists2[<%= i%>].clickRate" value="${kpi.clickRate }"/></td>
<td><input name="kpiLists2[<%= i%>].cost" value="${kpi.cost }"/></td>
<td><input name="kpiLists2[<%= i%>].averageCost"value="${kpi.averageCost }"/></td>
<td><input name="kpiLists2[<%= i%>].quailtyScore value="${kpi.quailtyScore }"/></td>
</tr>
</s:iterator>
Kpi类:
package com.yksuit.erp.taobao.promotion.data;
import java.util.Date;
/**
* Kpi entity. @author MyEclipse Persistence Tools
*/
public class Kpi implements java.io.Serializable {
// Fields
private Integer id;
private Product product;
private String keywords;
private Double price;
private Integer showTimes;
private Integer clickTimes;
private Double clickRate;
private Double cost;
private Double averageCost;
private Integer quailtyScore;
private Date date;
// Constructors
/** default constructor */
public Kpi() {
}
/** full constructor */
public Kpi(Product product, String keywords, Double price,
Integer showTimes, Integer clickTimes, Double clickRate,
Double cost, Double averageCost, Integer quailtyScore, Date date) {
this.product = product;
this.keywords = keywords;
this.price = price;
this.showTimes = showTimes;
this.clickTimes = clickTimes;
this.clickRate = clickRate;
this.cost = cost;
this.averageCost = averageCost;
this.quailtyScore = quailtyScore;
this.date = date;
}
// Property accessors
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public Product getProduct() {
return this.product;
}
public void setProduct(Product product) {
this.product = product;
}
public String getKeywords() {
return this.keywords;
}
public void setKeywords(String keywords) {
this.keywords = keywords;
}
public Double getPrice() {
return this.price;
}
public void setPrice(Double price) {
this.price = price;
}
public Integer getShowTimes() {
return this.showTimes;
}
public void setShowTimes(Integer showTimes) {
this.showTimes = showTimes;
}
public Integer getClickTimes() {
return this.clickTimes;
}
public void setClickTimes(Integer clickTimes) {
this.clickTimes = clickTimes;
}
public Double getClickRate() {
return this.clickRate;
}
public void setClickRate(Double clickRate) {
this.clickRate = clickRate;
}
public Double getCost() {
return this.cost;
}
public void setCost(Double cost) {
this.cost = cost;
}
public Double getAverageCost() {
return this.averageCost;
}
public void setAverageCost(Double averageCost) {
this.averageCost = averageCost;
}
public Integer getQuailtyScore() {
return this.quailtyScore;
}
public void setQuailtyScore(Integer quailtyScore) {
this.quailtyScore = quailtyScore;
}
public Date getDate() {
return this.date;
}
public void setDate(Date date) {
this.date = date;
}
}
不知道大家还有没有更加好的方法,我这种方法是不得已而为之,望大家指教!