[英]access struts employee object in javascript
I have list of employees on JSP page coming from struts action class. 我在JSP页面上有来自struts行动班的员工列表。 I want to access this list in my javascript code.
我想在我的JavaScript代码中访问此列表。 I tried following
我尝试了以下
In my JSP I have 在我的JSP中
<s:hidden value = "%{employeeList}" id = "employeeListId" />
In my JS file I have 在我的JS文件中
var employeeList= $("#employeeListId").val();
alert(employeeList);
But I get something like following. 但是我得到类似跟随的东西。
[com.lifetech.magellan.bean.empListColumns@6d234585, com.lifetech.magellan.bean.empListColumns@10c119d6, com.lifetech.magellan.bean.empListColumns@5eed22c0] [com.lifetech.magellan.bean.empListColumns @ 6d234585,com.lifetech.magellan.bean.empListColumns @ 10c119d6,com.lifetech.magellan.bean.empListColumns @ 5eed22c0]
I need to read each attribute of each employee such as employeeName, empNumber etc. 我需要阅读每个员工的每个属性,例如employeeName,empNumber等。
How to do that? 怎么做?
create array by jstl 通过jstl创建数组
var employeeList= {
<c:forEach items="${employeeList}" var="employee">
"${employee.id}": {
name:"${employee.employeeName}",
job:"${employee.employeeJob}",
},
</c:forEach>
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.