में एकाधिक सूची पास करें मेरे पास दो ऑब्जेक्ट्स Employee
और Department
कर्मचारी में dept_id
है। मैं जो करना चाहता हूं वह jsp पेज में एक तालिका में Employee
की सामग्री प्रदर्शित करता है। लेकिन dept_id
प्रदर्शित करने के बजाय मैं dept_name
Department
तालिका से प्रदर्शित करना चाहता हूं।स्प्रिंग एमवीसी नियंत्रक से जेएसपी
public ModelAndView viewEmployee(HttpServletRequest request,
HttpServletResponse response) throws Exception {
List<Employee> employeeList = employeeService.getAllEmployee();
List<Department> departmentList = new ArrayList<Department>();
for (Employee e : employeeList) {
departmentList.add(departmentService.getDepartment(e.getDept_id()));
}
Map<String, Object> model = new HashMap<String, Object>();
model.put("employee", employeeList);
model.put("department", departmentList);
return new ModelAndView("viewEmployee", "model", model);
}
viewEmployee.jsp
<table border="1px" bordercolor="black" width=80% align="center">
<tr>
<td>Name</td>
<td>Gender</td>
<td>Salary</td>
<td>Department</td>
<td>Action</td>
</tr>
<c:forEach items="${model.employeeList}" var="element">
<tr>
<td><c:out value="${element.name}" /></td>
<td><c:out value="${element.gender}" /></td>
<td><c:out value="${element.salary}" /></td>
<td>display Department Name here </td>
<td><a
href="<c:url value="editEmployee.htm">
<c:param name="emp_id" value="${element.id}"/>
</c:url>
">Edit</a>
<a
href="<c:url value="deleteEmployee.htm">
<c:param name="emp_id" value="${element.id}"/>
</c:url>
">Delete</a>
</td>
</tr>
</c:forEach>
</table>
किसी भी मदद की: अब तक मैं के रूप में मेरे नियंत्रक विधि है? मैं jsp पेज पर मानचित्र सामग्री प्रदर्शित करने में सक्षम नहीं हूं।
उपयोग कर सकते हैं आप अपने POJO के –