【发布时间】:2013-10-04 06:52:30
【问题描述】:
Hii i am running a named query and in my table i have multiple notifications for a corresponding userid so i need to get these multiple notification in a list and then show on my jsp
here is my code..
JAVA CODE
public ModelAndView getNotifications(int id){
System.out.println("Method ios called");
Session session = usermanagementSessionFactory.openSession();
System.out.println("after Getting Session");
int id1 = id;
System.out.println(id1);
Query query=(Query) session.getNamedQuery("getNotification");
query.setInteger("userId",id1);
List<Message> list1= query.list();
ModelAndView mv = new ModelAndView("notifications");
for(Message userData:list1)
{
String notifications=userData.getNotification();
boolean isNew=(boolean) userData.isNew();
ArrayList li = new ArrayList();
li.add(notifications);
//li.add(mname1);
if(isNew)
{
mv.addObject("loginsuccess" ,li);
}else
{
mv.addObject("loginsuccess" ,"There is no New Notifications");
}
}
return mv;
}
JSP FILE
<h3 style="margin-top:100px;"> <core:forEach items="${loginsuccess}" var="items">
<core:out value="${items}"></core:out>
</core:forEach>
它不工作只显示 tble 中的最后一个条目 sooplz 建议我需要做什么, 列表将如何获取所有记录 需要进行哪些更改 它不工作只显示 tble sooplz 中的最后一个条目建议我需要做什么, 列表将如何获取所有记录需要进行哪些更改
【问题讨论】:
标签: spring hibernate model-view-controller named-query