Spring Boot-通过P​​OST发送表数据

时间:2018-07-30 11:42:50

标签: java spring spring-mvc spring-boot spring-security

我需要将数据从jsp表发送到控制器。我将Model Attribute与list一起使用,但在控制器的POST方法中,列表大小始终为0。

@PreAuthorize(Utils.PRE_AUTHORIZE_ADMIN_ROLE + " or " + Utils.PRE_AUTHORIZE_AGENT_ROLE)
@RequestMapping(value = "/create", method = RequestMethod.POST)
public RedirectView createContract(ModelMap modelMap, @ModelAttribute("contractForm") ContractForm contractForm,
        HttpSession session,RedirectAttributes redirectAttrs) throws ParseException {
System.out.println(contractForm.getlSecurityCoreServiceProduct().size());
}

我在模型属性的自定义定义类中有一个实体的数组列表。

public class ContractForm {

     private List<SecurityCoreServiceProduct> lSecurityCoreServiceProduct = new ArrayList<SecurityCoreServiceProduct>();

public List<SecurityCoreServiceProduct> getlSecurityCoreServiceProduct() {
    return lSecurityCoreServiceProduct;
}

public void setlSecurityCoreServiceProduct(List<SecurityCoreServiceProduct> lSecurityCoreServiceProduct) {
    this.lSecurityCoreServiceProduct = lSecurityCoreServiceProduct;
}
}

JSP表主体

<tbody id="security_table_body">
<c:forEach items="${contractForm.lSecurityCoreServiceProduct}" var="securityCoreProduct" varStatus="status">
<tr>
<td>
<input type="number" id='hq' name="lSecurityCoreService[${status.index}].iContractID" class="form-control" value="${securityCoreProduct.iContractID}"/>
</td>
</tr>
</c:forEach>
</tbody>

0 个答案:

没有答案