前台页面获取servlet传过来的数据
servlet中的代码:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RequestDispatcher dispatcher = null; ServletContext servletContext = getServletContext(); LinkDAO linkDAO=LinkDAOFactory.getLinkDAOInstance(); List<Link> links=linkDAO.findAllLink(); request.setAttribute("LinkList", links); dispatcher=servletContext.getRequestDispatcher("index.jsp"); dispatcher.forward(request, response); }
这个servlet中的从数据库中获取的link列表需要在前台显示出来。前台页面可以用jstl标签配合EL标签的遍历标签来读取
<c:forEach items="${requestScope.LinkList}" var="link"> <li><a href="#">${link.title}</a></li> </c:forEach>
----------------
Lynx
The quieter you become,the more you are able to hear.