JSTL 概述

JSTL概述

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

 

JSTL的五库

I18N   java 编程

sql   sql编码

xml

functions

核心库       core

 

JSTL导入   

jsp指令taglib指令导入核心标签库

需要jar包

分别为jstl.jar和standard.jar。

 

常用标签

<c:if test=””>标签

其中test是返回boolean的条件

java

<%request.setAttribute("count", 10); %>

jstl

<c:if test="${count==10 }">

   xxxx

</c:if>

 

<c:forEach>标签

java 

User user=new User();

   user.setId(100);

   user.setName("张三");

   user.setPwd("123");

   session.setAttribute("user", user);

 

普通for

if(int i=0 ;i<=10; i++

<c:forEach begin="0" end="10" var=“uer”>

${uer}

</c:forEach>

 

增强for

for  productList--List<Product>

   for(Product product:productList){

      System.out.print(product.getName());

   }

<c:forEach items="要遍历的集合">

${}

</c:forEach>

 

posted @ 2019-04-13 21:38  小白WY  阅读(221)  评论(0编辑  收藏  举报