struts2 action 接受数组参数为Null的问题

 public List<FormulaDetail> formulaDetails;
public List<FormulaDetail> getFormulaDetails() {
        return formulaDetails;
    }
    public void setFormulaDetails(List<FormulaDetail> formulaDetails) {
        this.formulaDetails = formulaDetails;
    }

JSP传过来的数组formulaDetails[0].count不能被struts2接收,经过查询发现是FormulaDetail类没有缺省的构造函数

public FormulaDetail() {
    }

只有一个带参数的函数

/** full constructor */
    public FormulaDetail(Integer formulaId, Integer goodsCategory,
            Integer percent) {
        this.formulaId = formulaId;
        this.goodsCategory = goodsCategory;
        this.percent = percent;
    }

讲缺省构造函数添加之后,成功接收数组参数

原文地址:https://www.cnblogs.com/yangchengInfo/p/3514979.html