..._model.addattribute的值传不到前台页面了">
赞
踩
1.直接传对象集合
List<Area> proList = new ArrayList<>();
model.addAttribute("proList2", proList);
<select id="province" name="provinceCode">
<option value="" selected>--请选择省--</option>
<c:forEach var="pro" items="${proList2}" varStatus="status">
<option value="${pro.code}">${pro.name}</option>
</c:forEach>
</select>
2. 转换为jsonString
String jsonString = JSON.toJSONString(proList);
model.addAttribute("proList", jsonString);
<input type="hidden" name="proList" id="proList" value="<c:out value="${proList}" />">
var provinces = new Array();
if($('#proList').val()!=''){
provinces = eval('(' + $('#proList').val() + ')');
for ( var i = 0; i <provinces.length; i++){
console.log(provinces[i].code);
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。