手动点击刷新后才显示
js(index页面,一进去ready完后,进controller)
$(function(){ var url = "<%=request.getContextPath()%>/announcement/selectIndexLimits"; $.post(url); });
controller
@RequestMapping("/selectIndexLimits") public String selectIndexLimits(HttpServletRequest request){ List<Announcement> announcementIndex = announcementService.selectLimits(0, 5); request.getSession().setAttribute("announcementIndex", announcementIndex); // model.addAttribute("announcementIndex", announcementIndex); return "index"; }
前台显示是el
<c:forEach items="${announcementIndex}" var="announcementIndex">
<tr>
<td><%=++annoi%></td>
<td><a onclick='showAnnoContent(this)'>${announcementIndex.title }</a></td>
<td hidden='hidden'>${announcementIndex.name }</td>
<td hidden='hidden' class='annoContent'>${announcementIndex.content }</td>
<td>${announcementIndex.time}</td>
</tr>
</c:forEach>
已解决,后台跳转失效,但就算有效此方法也不可取。换了写法