.jsp
<c:forEach items = "${allContacts}" var="contact">
<c:out value="${contact.firstName}"/>,
<c:out value="${contact.lastName}"/>
</c:forEach>
联系服务.java
public static List listContacts() {
return toList(contacts);
}
private static List toList(Map contacts) {
List contactList = new ArrayList();
Iterator iterator = contacts.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
Contact contact = (Contact) entry.getValue();
contactList.add(contact);
}
return contactList;
}
ListContactsController.java
public class ListContactsController extends AbstractController {
public ListContactsController() {
}
public ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
List allContacts = ContactService.listContacts();
return new ModelAndView("ListContacts","allContacts", allContacts);
}
}
我正在尝试列出allContacts
,但仅显示“,”作为输出。数据显示在 GET 中,但不显示在网页中。问题是什么?