JSTL(C标签)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38323645/article/details/82930820

在这里插入图片描述
c:out

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   <!-- 引入jsp标签库 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>Insert title here</title>
</head>

<body>

<%
	pageContext.setAttribute("people", "小二");

%>
<c:out value="jstl大爷你好"></c:out>
<h2><c:out value="${people}"></c:out></h2>
</body>
</html>

在这里插入图片描述
c:catch
在这里插入图片描述
c:choose
在这里插入图片描述
c:forEach

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="po.*"%>
<%@ page import="java.util.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>Insert title here</title>
</head>
<body>
<%
	String dogs[]={"小黑","小黄","小白","小小"};
    pageContext.setAttribute("dogs",dogs);
%>
<c:forEach var="e" items="${dogs }"><!-- 下标从0开始 -->
	${e }
</c:forEach>
<hr/>
<c:forEach var="e" items="${dogs }" step="2"><!-- 步进2  小黑小白-->
	${e }
</c:forEach>
<hr/>
<c:forEach var="e" items="${dogs }" begin="1" end="2"><!--小黄小白-->
	${e }
</c:forEach>
<hr/>
<%
	List<People> pList=new ArrayList<People>();
    pList.add(new People(1,"张三",10));
    pList.add(new People(2,"李四",20));
    pList.add(new People(3,"王五",30));
    pageContext.setAttribute("pList",pList);
%>
<table>
	<tr>
		<th>编号</th>
		<th>姓名</th>
		<th>年龄</th>
	</tr>
	<c:forEach var="p" items="${pList }">
		<tr>
			<td>${p.id }</td>
			<td>${p.name }</td>
			<td>${p.age }</td>
		</tr>
	</c:forEach>
</table>
</body>
</html>

在这里插入图片描述
c:forTokens
在这里插入图片描述
c:if
在这里插入图片描述
c:impport
在这里插入图片描述
c:url
在这里插入图片描述
c:redirect
在这里插入图片描述
target.jsp
在这里插入图片描述
c:set
在这里插入图片描述
c:remove
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_38323645/article/details/82930820