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 建议我我是什么需要做什么,列表将如何获取所有记录需要哪些更改