paramCheckList是一个集合,在页面可以这样获取:
<s:hidden id="paramCheckListId"
value="%{@org.apache.struts2.json.JSONUtil@serialize(paramCheckList)}"></s:hidden>
js代码:
var pList=$("#paramCheckListId").val()
var listData=$.parseJSON(pList)//解析json字符串
$.each(listData,function(idx,item){ //循环对象取值
alert(item.name)
})
亲,java代码是在服务器端执行的,js代码才是在客户端执行的~固你的js应该只是接收后台执行结果,js套java以及jstl都是不对的。如果后台是集合对象是ArrayList可以这样写~因为它的toString方法返回结果就是字符串形式的数组。eg."[1,2,3]"<script type="text/javascript"var list = ${sinList}if(getListIdTwo[i].checked){for(){}}</scriptif(getListIdTwo[i].checked){<%int k=0%for(j=0j<${sinSize}j++){alert(j)var newInputId = getListIdTwo[i].valuevar sinId = ${sinList[k]}<%k++%//if(newInputId == ${sinList[j]}){//}////{// alert("对不起,你需要删除类别包含原设备类别参数。只能删除新增的类别参数!")//}<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>list</title>
</head>
<body>
<ul id="list">
<li v-for="item in items">
{{ item.message }}
</li>
<br>
<li v-for="(item,index) in items">
{{index}}:{{ item.message }}
</li>
<br>
<template v-for="item in items">
<li>{{ item.message }}</li>
<li>--------------</li>
</template>
<br>
<li v-for="value in object">
{{ value }}
</li>
<br>
<li v-for="(value,key) in object">
{{key}}:{{ value }}
</li>
<br>
<li v-for="n in 10">{{ n }}</li>
<br>
<li v-for="n in numbers">{{ n }}</li>
</ul>
<!--of 替代 in-->
<script src="js/vue.js"></script>
<script>
var vm = new Vue({
el:"#list",
data: {
items: [
{message: 'Foo' },
{message: 'Bar' }
],
object: {
FirstName: 'John',
LastName: 'Doe',
Age: 30
},
numbers: [ 1, 2, 3, 4, 5 ]
},
computed:{
list:function(){
this.items.push({ message: 'Baz' })
},
evenNumbers: function () {
return this.numbers.filter(function (number) {
return number % 2 === 0
})
}
}
})
</script>
</body>
</html>