• springmvc使用JSTL标签库


    今天使用SpringMvc,在页面上用JSTL来做标签库进行解析,方法是:

    在JSP页面上引入<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

    在pom.xml中引入JAR包:

                <dependency>  
                    <groupId>javax.servlet</groupId>  
                    <artifactId>jstl</artifactId>  
                    <version>1.2</version>  
                    <scope>runtime</scope>  
                </dependency>  
            <dependency>
                <groupId>taglibs</groupId>
                <artifactId>standard</artifactId>
                <version>1.1.2</version>
            </dependency>

    注意不要引错包,不要写成

            <dependency>
                <groupId>javax.servlet.jsp.jstl</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
            </dependency>

    也不要servlet-api.jar jsp-api.jar这些jar包

    在jsp头添加<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

    4、使用<c:foreach>标签

    <c:forEach var="user"  items="${users}" >

         <tr><td>${user.userName }</tr>

    </c:forEach>

    注:在controller中已经把list集合set到httpServletRequest中了,c标签中直接取就行 req.setAttribute("users", list);

  • 相关阅读:
    山丽防水墙客户端的卸载
    还原冰点密码清除
    STP学习总结
    NTFS权限设置时卡死
    SQL server 2000安装时“以前的某个程序安装已在安装计算机上创建挂起”
    Projecet客户端登陆无法通过验证
    Linux-nftables
    Linux-kernel-timeline
    blog编辑技巧
    Linux-swap
  • 原文地址:https://www.cnblogs.com/htys/p/3769620.html
Copyright © 2020-2023  润新知