jstl core

jstl core 的标签使用

 

jstl-core.jsp:

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@page import="java.util.Date, space.learn.jstl.Fruit"%>
<%@ taglib prefix='c' uri="http://java.sun.com/jsp/jstl/core" %>
<html>
	<head>
		<title>jstl core taglib learn</title>
		<style type="text/css">
			body {background-color: black;color: white;}
			span {text-align: center;color: green;background-color: yellow;}
			.notice {color: rgb(250,37,62);}
			hr { background-color: fuchsia; height: 5px;}
			link {color: red;}
	
}
		</style>
	</head>
	<body>
		<% request.setAttribute("space","<font color=red>I am space.</font>"); %>
		
		<span>c:out 输出信息:</span><br/>
		<jsp:useBean id="str" class="String" />
		<c:out value="${space}" /><br/>
		<c:out value="${space}" escapeXml="false" /><br/>
		<c:out value="${str_not_exist}" default="I don't know the time." /><br/>
		<hr/>
		
		<span>c:set 设置jsp作用域变量的属性:</span><br/>
		没有测试成功 ...
		<hr/>
		
		<span>c:catch 捕捉异常:</span><br/>
		没有尝试 ...
		<hr/>
		
		<span>c:if 条件语句:</span><br/>
		<% request.setAttribute("fly", "true"); %>
		<c:if test="${fly}" >
			fly to the sky
		</c:if>
		<hr/>
		
		<span>c:choose when otherwise 多次判断条件语句:</span><br/>
		<% request.setAttribute("sky", true); %>
		<c:choose>
			<c:when test="${sky}">
				sky==true
			</c:when>
			<c:otherwise>
				sky==false
			</c:otherwise>
		</c:choose>
		<hr/>
		
		<span>c:forEach 循环语句:</span><br/>
		<% 
			Integer[] nubs={0,1,2,3,4,5,6,7,8,9};
			request.setAttribute("nubs",nubs);
		%>
		<c:forEach items="${nubs}" var="nub" begin="1" end="7" step="2">
			${nub},
		</c:forEach>
		<hr/>
		
		<span>forTokens使用多个分隔符</span><br/>
		<c:forTokens items="A,B-C,D.E,F,G_HipHot@I" delims=",-_@."  var="abc" varStatus="st">
		${abc},index=${st.index}<br>
		</c:forTokens>
		<hr/>
		
		<span>使用forEach分割字符串</span><br/>
		<c:forEach items="使用,forEach,进行基本的分割,分割只能按照逗号,,"  var="abc" varStatus="st">
		${abc}<br>
		</c:forEach>
		<hr/>
		
		<span>c:url 跳转:</span><br/>
		<c:url value="http://g.cn" var="google">
			<c:param name="str" value="java" />
		</c:url>
		<a href="${google}">google</a>
		<hr/>
		
		<span>c:redirect 重定向:</span><br/>
		使用下面的语句可以重定向,为了防止重定向,注释掉了<br/>
		<%-- <c:redirect url="${google}"></c:redirect> --%>
		<hr/>
		
	</body>
</html>
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值