var rouletteArr = new Array(); //["기프티콘","마일리지 500점","마일리지 100점","기프티콘","마일리지 2,000점","마일리지 50점"];
<c:forEach items="${resultList}" var="item">
rouletteArr.push("${item.rouletteSeq}");
</c:forEach>
vo List 일때는 이렇게
var dataList = new Array();
var dataObj = new Object();
var categoryName = "";
<c:forEach items="${resultList}" var="result">
categoryName = "${result.categoryName}";
dataObj[categoryName] = new Object();
dataObj[categoryName].categoryName = "${result.categoryName}";
dataObj[categoryName].weekStartDt = "${result.weekStartDt}";
dataObj[categoryName].weekEndDt = "${result.weekEndDt}";
dataObj[categoryName].sessionAll = "${result.sessionAll}";
dataObj[categoryName].sessionDistinct = "${result.sessionDistinct}";
dataObj[categoryName].loginAll = "${result.loginAll}";
dataObj[categoryName].loginDistinct = "${result.loginDistinct}";
dataList.push(dataObj[categoryName]);
</c:forEach>
사용할때는 이렇게
$.each(dataList, function(index){
categoryStr += "<category name='"+ this.weekStartDt + " - " + (this.weekEndDt).substring(5) + "' /> \n";
});
forEach문으로 루프 돌려서 Array 오브젝트에 넣어주면 됨.
[출처] java List to javascript Array , java vo list to javascript array list |작성자 키키
http://hongy0225.blog.me/220183635327
댓글 없음:
댓글 쓰기