JSTL——JSP Standard Tag Library JSP标志标签库
来源:互联网 发布:李嘉诚撤资 知乎 编辑:程序博客网 时间:2024/05/29 14:03
5个标签库:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/function" %>
JSTL的core标签:
<c:forEach var="" items=""></c:forEach>
<c:if test=""></c:if>
<c:choose>
<c:when></c:when>(可以有多个)
<c:otherwise></c:otherwise>(只能有一个)
</c:choose>
例:
<%
int i = (int)(Math.random()*4);
pageContext.setAttribute("i",i);
%>
<c:choose>
<c:when test="${i==1}">
产生随机数1
</c:when>
<c:when test="${i==2}">
产生随机数2
</c:when>
<c:when test="${i==3}">
产生随机数3
</c:when>
<c:otherwise>
error.
</c:otherwise>
</c:choose>
产生-100到100的随机数:
<%
Random r = new Random(System.currentTimeMillis());
int i = (int)(Math.random()*101);
if(r.nextBoolean()){
pageContext.setAttribute("i",i);
}
else{
pageContext.setAttribute("i",-i);
}
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/function" %>
JSTL的core标签:
<c:forEach var="" items=""></c:forEach>
<c:if test=""></c:if>
<c:choose>
<c:when></c:when>(可以有多个)
<c:otherwise></c:otherwise>(只能有一个)
</c:choose>
例:
<%
int i = (int)(Math.random()*4);
pageContext.setAttribute("i",i);
%>
<c:choose>
<c:when test="${i==1}">
产生随机数1
</c:when>
<c:when test="${i==2}">
产生随机数2
</c:when>
<c:when test="${i==3}">
产生随机数3
</c:when>
<c:otherwise>
error.
</c:otherwise>
</c:choose>
产生-100到100的随机数:
<%
Random r = new Random(System.currentTimeMillis());
int i = (int)(Math.random()*101);
if(r.nextBoolean()){
pageContext.setAttribute("i",i);
}
else{
pageContext.setAttribute("i",-i);
}
%>
产生的随机数是:${i }
阅读全文
1 0
- JSTL——JSP Standard Tag Library JSP标志标签库
- JSTL(JSP Standard Tag Library ,JSP标准标签库)
- JSTL(JSP Standard Tag Library,JSP标准标签库)
- JSTL : javaserverpages standard tag library JSP标准标签库
- JSP标准标签库 JSTL(JavaServer Pages Standard Tag Library)
- JSTL(JSP Standard Tag Library)
- JSTL (JSP Standard Tag Library)
- JSP:JSTL--JSP Standard TAG Library
- 自定义标签、JSTL(JSP Standard Tag Library)
- JSP Standard Tag Library (JSTL)介绍
- JSP Standard Tag Library (JSTL)介绍
- JSP - Standard Tag Library (JSTL) Tutorial
- JSTL(JSP标准标签库/JavaServer Pages Standard Tag Library)
- JSP Standard Tag Library
- JSP标准标记库(JSP Standard Tag Library,JSTL)使用入门
- JSTL(Jsp Standard Tag Library) Kick Start(1)
- Core JSTL: Mastering the JSP Standard Tag Library
- Introduction to JSP Standard Tag Library (JSTL Basics)
- emacs安装
- 《超越感觉》读后感
- 关于RabbitMQ的一些问题
- 获得全表扫描的对象
- BZOJ 2007 对偶图 解题报告
- JSTL——JSP Standard Tag Library JSP标志标签库
- 条件判断
- 十三、Shell函数:Shell函数返回值、删除函数、在终端调用函数
- mysql的内连接和外连接小例子
- msbuild.exe参数(.net 2.0)
- c++继承和派生
- cookie和session详解
- CF295B Greg and Graph(离线+Floyd)
- javabean的使用原则