嘿如何在jsp页面的标签中使用循环?
我想用JSTL数据传入数据表
我的代码是这样的:
$(document).ready(function() {
/* Init DataTables */
var startString = "[";
var mainString = "";
var endString = "]";
var temp = ${k.size()};
<c:forEach items="${k}" var="stdn" varStatus="status">
temp--;
if (temp === 0) {
mainString = mainString + "{key:\"" + "${stdn.key}" + "\",name:\"" + "${stdn.value.name}" + "\",rollno:\"" + "${stdn.value.rollNo}" + "\",marks:\"" + "${stdn.value.marks}" + "\"}";
} else {
mainString = mainString + "{key:\"" + "${stdn.key}" + "\",name:\"" + "${stdn.value.name}" + "\",rollno:\"" + "${stdn.value.rollNo}" + "\",marks:\"" + "${stdn.value.marks}" + "\"},";
}
</c:forEach>
var finalString = startString + mainString + endString;
var final = eval(finalString);