JSP中使用标签循环遍历元素
4057
1、forEach标签元素
[html]
view plain
copy
2、
使用forEach标签时需要在JSP页面中引入JSTL标签库,如下:
[html]
view plain
copy
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
3、forEach标签使用实例
1)UserService.java中的getallUser()方法查询用户信息
[html]
view plain
copy
public List
2)logServlet
.java主要用来将查询到用户信息保存到Session对象中,用来进行输出
[java]
view plain
copy
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=utf-8"); UserService service = new UserService(); List
3)allpage.jsp使用forEace迭代标签结合EL表达式
将保存到session对象中的用户信息取出且输出到页面中
[html]
view plain
copy
${user.uid} ${user.uname} ${user.username} ${user.password} ${user.address} ${user.iphome}