什么是JSTL
JSTL(JSP Standard Tag Library),
JSP标准标签库
可以嵌入在jsp页面中使用标签的形式
完成业务逻辑等功能
jstl出现的目的同el一样
也是要代替jsp页面中的脚本代码

JSTL标准标签库有5个子库
Core :核心库
http://java.sun.com/jsp/jstl/core
前缀:c
I18N:国际化库
http://java.sun.com/jsp/jstl/fmt
前缀:fmt
SQL
http://java.sun.com/jsp/jstl/sql
前缀:sql
XML
http://java.sun.com/jsp/jstl/xml
前缀:x
Functions
http://java.sun.com/jsp/jstl/functions
前缀:fn

引入标签库
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
if标签
<c:if test="${1==1 }">满足条件时,
中间的内容才会显示出来</c:if>
通过是结合EL表达式一起使用,
EL从域中取数据,使用JSTL进行判断或者遍历

if标签使用
1.登录成功时,把用户写到session域当中

2.在首页当中进行判断,从session域当中取数据
3.通过EL结合JSTL进行判断

foreach标签
第一种:普通循环

第二种:增加for循环
遍历字符串集合

遍历对象集合

遍历map

网友评论