
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
这个就是核心标签库。
prefix="这里随便起一个名字就行了,核心标签库,大家默认的叫做c,你随意。"
第三步:在需要使用标签的位置使用即可。表面使用的是标签,底层实际上还是java程序
<c:forEach items="${stuList}" var="s">
id:${s.id} name:${s.name}<br>
</c:forEach>
<%@taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core” %>
以上uri后面的路径实际上指向了一个xxx.tld文件。

tld文件实际上是一个xml配置文件。
在tld文件中描述了“标签”和“java类”之间的关系。
以上核心标签库对应的tld文件是:c.tld文件。它在哪里。
在jakarta.servlet.jsp.jstl-2.0.0.jar里面META-INF目录下,有一个c.tld文件。
源码解析:配置文件tld解析
<tag>
<description>对该标签的描述</description>
<name>catch</name> 标签的名字
<tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class> 标签对应的java类。
<body-content>JSP</body-content> 标签体当中可以出现的内容,如果是JSP,就表示标签体中可以出现符合JSP所有语法的代码。例如EL表达式。
<attribute>
<description>
对这个属性的描述
</description>
<name>var</name> 属性名
<required>false</required> false表示该属性不是必须的。true表示该属性是必须的。
<rtexprvalue>false</rtexprvalue> 这个描述说明了该属性是否支持EL表达式。false表示不支持。true表示支持EL表达式。
</attribute>
</tag>
<c:catch var="">
JSP....
</c:catch>
c:if
<c:if test="${not empty param.username}">
<h1>欢迎您,${param.username}</h1>
</c:if>
c:forEach
<%
//创建List集合
List<Student> studentList = new ArrayList<>();
//创建学生,将学生加入到集合中
Student s1 = new Student("123","Jack");
Student s2 = new Student("456","Merry");
Student s3 = new Student("789","Quick");
studentList.add(s1);
studentList.add(s2);
studentList.add(s3);
//将集合放入请求域
request.setAttribute("stuList",studentList);
%>
<c:forEach items="${stuList}" var="s">
id:${s.id} name:${s.name}<br>
</c:forEach>
<c:choose>
<c:when test="${param.age < 18}">
青少年
</c:when>
<c:when test="${param.age < 35}">
青年
</c:when>
<c:when test="${param.age < 55}">
中年
</c:when>
<c:otherwise>
老年
</c:otherwise>
</c:choose>