Controller
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
List<Test> testList= (id);
("testList", testList);
return prefix + "/edit";
}
[[${testList}]]可取出从controller传过来的testList对象,该功能实现了对查询到的testList集合里的所有Test对象的value值的累加,并把最后累加值赋予input。
......
<input name="totalValue" value="0" style=" border-width:0;color:red;" class="form-control" type="text" maxlength="30" readonly="readonly">
......
function sumAmount(){
var totalAmount = 0;
for(var i = 0; i < [[${testList}]].length; i++){
var result = [[${testList}]][i];
totalAmount = accAdd(totalAmount, );
}
$("input[name='totalValue']").val(totalAmount);
}
......