JSTL标签之core标签的使用
2018-01-24 15:36
381 查看
参考:http://blog.csdn.net/qq_25827845/article/details/53311722
核心标签库的导入
核心标签库的导入
<%@ taglib prefix="c"uri="http://java.sun.com/jstl/core" %>常用标签:
1.out标签:<c:out value=""/> 2.set标签:<c:set var="" value=""/> var变量名 value变量的值 3.remove标签:<c: remove var="a"/> 删除所有域中变量a 4.url标签:<c:url value="/"/> 输出上下文路径:/项目名/ 5.if标签:<c:if test""> <c:out value=""/> </c:if> 满足test中条件时执行if标签中内容 6.choose标签:choose标签对应Java中的if/else if/else结构。when标签的test为true时,会执行这个when的内容。当所有when标签的test都为false时,才会执行otherwise标签的内容。 <c:choose> <c:when test=""> </c:when> <c:when test=""> </c:when> <c:when test=""> </c:when> <c:otherwise></c:otherwise> </c:choose>
7.forEach标签:循环标签 (1)使用循环变量:指定开始和结束值 <c:forEach var="i" begin="1" end="10"> <c:set var="sum" value="${sum+i}"/> </c:forEach> (2)遍历集合 <% String[] names = {"zhangSan", "liSi", "wangWu", "zhaoLiu"}; pageContext.setAttribute("ns", names); %> <c:forEach var="item" items="${ns }"> <c:out value="name: ${item }"/><br/> </c:forEach> forEach中的属性varStatus用来获取变量的状态 例:<c:forEach var="item" items="${ns }" varStatus="vs"> <c:if test="${vs.first }"></c:if> <c:if test="${vs.last }"></c:if> <c:out value="${vs.count } "/> <c:out value="[${vs.index }]: "/> <c:out value="name: ${vs.current }"/><br/> </c:forEach> count:int型 当前已遍历元素的个数 index:int型 当前元素下标 first:Boolean型 是否为第一个元素 last:Boolean型 是否为最后一个元素 current:Object型 表示当前项目
相关文章推荐
- 使用jstl标签时提示The absolute uri: http://java.sun.com/jsp/jstl/core cannot
- 【JSP】JSTL使用core标签总结(不断更新中)
- 【JSP】JSTL使用core标签总结
- JSTL 核心标签库(Core tag library)使用
- JSTL标签之core标签的使用
- 标准标签库(Jstl)的核心标签(Core)的使用
- JSTL core c 标签的使用
- 用myeclipse2015 stable 2.0新建jsp后,无法使用jstl/core标签
- JSP中<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>标签的使用
- 【转】JSTL 核心标签库 使用
- <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>标签再使用时报错
- [转]JSTL 核心标签库的使用
- jstl的使用(四):核心标签库之URL操作标签
- 报错:jstl标签——The absolute uri: http://java.sun.com/jsp/jstl/core cannot beresolved in either web.xml o
- JSTL的时间格式化标签的使用
- JSTL核心标签库的使用方法和示例
- 【错误解决】[Maven]使用Maven配置Jstl出现异常:The absolute uri: http://java.sun.com/jsp/jstl/core cannot...
- 使用JSTL标签的步骤
- JSP页面中使用JSTL标签出现无法解析问题解决办法
- 使用jstl标签库实现URL地址重写