JSTL


1.core_Tags
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="变量名" scope="page/session/request/application" value="值"/>
<c:set var="变量名" scope="page/session/request/application">值</c:set>
<c:remove var="变量名" scope="page/session/request/application"/>
<c:out value=${}/} 从小到大的范围查找变量
**********************************************************
<c:if test="${empty var}"></c:if>
**********************************************************
<c:choose>
<c:when test="${pageScope.var/session.var/...}"></c:when>
<c:when test="${}"></c:when>
<c:otherwise></c:otherwise>
</c:choose>
**********************************************************
<forEach items="包含要迭代的内容的数据结构对象"
var="用户指定的当前正在迭代的元素"
varStatus="当前元素的状态(count|index|first|last)" count执行的次数,index索引值,first是否为第一个,last是否为最后一个
begin="迭代开始的位置"
end="迭代结束的位置"
step="迭代的步长" >
</forEach>
**********************************************************eg:
<c:forTokens items="字符串" var="当前字符串" varStatus="" delims="定界符">
</c:forTokens>
**********************************************************
<c:import uri="" var=""/>
<c:url value="">
<c:param name="" value=""/>
</c:url>
<c:redirect url=""/>
2.sql_Tags
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="sql"%>
连接
<sql:setDataSource var="" dirver="" url="" user="" password=""/>
操作
<sql:query dateSource="${}" var="结果集">select</sql:query>
<sql:update dateSource="${}">insert</sql:query>
<sql:update dateSource="${}">delete</sql:query>
事务
<sql:transaction dataSource="">
<sql:update var="">insert/update/delete</sql:update>
<sql:query var="">select</sql:query>
</sql:transaction>
显示
<c:forEach items="${结果集.rows}" var="记录" varStatus="s">
<h1 align="center">${s.count}|${记录.dd}</h1>
</c:forEach>
**********************************************************
3.XML_Tags
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="x"%>
<x:parse var=""></x:parse>
<x:out select=""/>
4.Tag_files
<%@taglib tagdir="/WEB-INF/tags" prefix="tt"%>
<%@attribute name="" required="" rtexprvalue=""%>
<%@variable name-from-attribute="" alias="" scope="AT_BEGIN"%>
<c:forEach begin="" end="" varStatus="">
<c:set var="" value=""/>
<jsp:doBody/>
</c:forEach>
00000000000000000000000示例0000000000000000000000000
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<br>****************if*************************
<c:if test="${empty param.user}" var="rst">
<h1 align="center">Body</h1>
</c:if>
${rst}
<br>****************set*************************
<c:set var="data" value="page" scope="page" />
<c:set var="data" value="request" scope="request" />
<c:set var="data" value="session" scope="session" />
<c:set var="data" value="application" scope="application" />
<c:remove var="data" scope="page"/>
<c:remove var="data" scope="request"/>
<c:remove var="data" scope="session"/>
<h1>${data}1</h1>
<h1><c:out value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" /></h1>
<h1><c:out value="${data}2" /></h1>
<h1><c:out value="${pageScope.data}3" /></h1>
<h1><c:out value="${requestScope.data}4" /></h1>
<h1><c:out value="${sessionScope.data}5" /></h1>
<h1><c:out value="${applicationScope.data}6" /></h1>
<br>****************choose*************************
<c:set var="age" value="15" scope="page"/>
<c:choose>
<c:when test="${age < 10}">
<h1><font color="red">
</c:when>
<c:when test="${age < 20}">
<h1><font color="blue">
</c:when>
<c:otherwise>
<h1><font color="black">
</c:otherwise>
</c:choose>
Hello</font></h1>
<br>******************forEach***********************
<c:set var="name" value="20" scope="page"/>
<c:forEach begin="${age}" end="${name}" step="1" varStatus="a" var="v">
<h1 align="center">${a.first}|${a.last}|${a.index}|${a.count}|${v}</h1>
</c:forEach>
<br>********************catch*********************
<c:catch var="e">
<%
String str = null;
String str1 = str.toLowerCase();
%>
</c:catch>
${e}
<br>*******************forTokens**********************
<c:forTokens items="1|23|456,7,89" var="v" varStatus="a" delims=",|">
<h1 align="center">${a.count}-${v}</h1>
</c:forTokens>
<br>*******************sql**********************
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<sql:setDataSource driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@127.0.0.1:1521:mumu" user="liulibo" password="liulibo"
var="ds" />

<sql:update dataSource="${ds}">
insert into mumu(dd) values(sysdate)
</sql:update>

<sql:transaction dataSource="${ds}">
<sql:update>
insert into mumu(dd) values(sysdate)
</sql:update>
</sql:transaction>

<sql:query dataSource="${ds}" var="rs">
select * from mumu
</sql:query>
<c:forEach items="${rs.rows}" var="v" varStatus="s">
<h1 align="center">${s.count}|${v.dd}</h1>
</c:forEach>
<sql:update dataSource="${ds}">
delete from mumu
</sql:update>
*****************redirect************************
<c:if test="false">
<c:redirect url="/lookup.jsp"/>
</c:if>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值