Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

, tag

, tag

JSP Standard Label LibraryJSP Standard Tag Library

These tags encapsulate the for, while, and do-while loops in Java.

By comparison, thetag is a more general-purpose tag because it iterates over the objects in a collection.

The tag splits a string into an array by specified delimiters and then iterates over them.


forEach Syntax







    ...

forTokens Syntax





property

The tag has the following attributes:

property Description Whether it is required Default value
items The information to be looped over No None
begin The starting element (0 = first element, 1 = second element) No 0
end The last element (0 = first element, 1 = second element) No Last element
step The step size of each iteration No 1
var The name of the variable representing the current item No None
varStatus The name of the variable representing the loop status No None

The tag is used together with theThe tags have similar attributes, but thehas another attribute:

property Description Whether it is required Default value
delims Separators Is None

Example Demonstration



<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

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





c:forEach 标签实例







   Item 

The running result is as follows:



Item 1

Item 2

Item 3

Item 4

Item 5


Demo Example



<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

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





c:forTokens 标签实例







   

The running result is as follows:



google

runoob

taobao


JSP Standard Label LibraryJSP Standard Tag Library