了解了基本的标签的底层实现,可以看系统定义的强大的标准标签
1、首先引入两个jar包
2、基本语法
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:out value="你好" ></c:out>
核心标签库
c:out
c:set
c:remove
c:catch
c:if
c:choose c:when c:otherwise
c:forEach
c:fortokens
c:import
c:url
c:redirect
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>c_out</title> </head> <body> <%-- c:out --%> <% pageContext.setAttribute("userName","lisaRong"); %> <c:out value="${userName }" ></c:out><br> <c:out value="${userName2 }" default="某人" ></c:out><br> <%-- c:set --%> <c:set var="people" value="james" scope="request"></c:set> <c:out value="${people }" ></c:out><br> <jsp:useBean id="per" class="com.zhiqi.model.Person" scope="page"></jsp:useBean> <c:set property="id" target="${per }" value="10010"></c:set> <c:set property="name" target="${per }" value="丽丽"></c:set> <c:set property="age" target="${per }" value="24"></c:set> <p>${per.id }</p> <p>${per.name }</p> <p>${per.age }</p> <c:remove var="people" scope="request"></c:remove> <c:out value="${people }" default="没人么?"></c:out><br> <%--异常捕获 --%> <c:catch var="errorMsg"> <% int a=1/0; %> </c:catch> <p>${errorMsg }</p> <c:if test="${per.age>18 }" var="r" scope="page"> <p>年龄:${per.age }</p> </c:if> <c:set property="age" target="${per }" value="16"></c:set> <c:if test="${per.age<18 }" var="result" scope="page"> <p>未成年</p> </c:if> </body> </html>