前提:c标签的引入:

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

一:在<c:forEach>中添加序号的方法:

在<c:forEach>标签中添加属性:varStatus;

然后${varStatus的属性值.index}:序号从0开始;${varStatus的属性值.index+1}:序号从1开始

OR直接:${varStatus的属性值.count}:序号从1开始

例子如下:

            <tr height="30">
			    <th width="130" >序号:</th>
            </tr>
            <c:forEach items="${result }" var="res" varStatus="status" >
			<tr>
				<td>${status.index+1 }</td>
            </tr>

效果如下:

有关<c>标签中常用属性的使用 

二:对c标签中数据的选择和判断

这里我们要用到如下几个标签:

<c:choose>
    <c:when test="${res.vendibility eq 0 }">test</c:when>
    <c:otherwise>${res.vendibility}</c:otherwise>  
</c:choose>
<c:choose> 本身只当做<c:when>和<c:otherwise>的父标签
<c:when> <c:choose>的子标签,用来判断条件是否成立
<c:otherwise> <c:choose>的子标签,接在<c:when>标签后,当<c:when>标签判断为false时被执行

 三:有关fn函数的使用:

有关<c>标签中常用属性的使用

 jstl标签库fn函数介绍:

stl标签库fn函数就是在jsp页面或js代码里面使用的函数,它是建立在EL表达式基础上的表达式函数,格式为 ${ns:methodName(args....)},一般会结合jstl标签库核心标签C标签使用。

fn函数使用示例:

<c:if test="${fn:contains(name, searchString)}"></c:if>
    var arrStr = ${fn:join(array, ";")};

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2021-11-04
  • 2021-07-17
  • 2022-12-23
  • 2021-07-13
猜你喜欢
  • 2022-12-23
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2021-10-20
相关资源
相似解决方案