Skip to content

Commit 09f4c9e

Browse files
author
xiachaochao
committed
jstl资料提交
1 parent 8d41c5d commit 09f4c9e

10 files changed

Lines changed: 175 additions & 0 deletions

File tree

JavaWeb/WebContent/JSTL/MLDN/if_demo.jsp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<title>Insert title here</title>
99
</head>
1010
<body>
11+
<c:if test="${param.ref=='mldn'}" var="res1" scope="page">
12+
<h3>欢迎${param.ref}</h3>
13+
</c:if>
1114
<c:if test="${10<30}" var="res1">
1215
<h3>10比30小</h3>
1316
</c:if>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5+
<html>
6+
<head>
7+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8+
<title>Insert title here</title>
9+
</head>
10+
<body>
11+
<%
12+
String info[] = { "www", "crazy", "java" };
13+
pageContext.setAttribute("ref", info);
14+
%>
15+
<h3>输出全部</h3>
16+
<c:forEach items="${ref}" var="mem">
17+
${mem}
18+
</c:forEach>
19+
<h3>输出全部(间隔为2)</h3>
20+
<c:forEach items="${ref}" var="mem" step="2">
21+
${mem}
22+
</c:forEach>
23+
<h3>输出前两个:
24+
<c:forEach items="${ref}" var="mem" begin="0" end="1">
25+
${mem}
26+
</c:forEach>
27+
</h3>
28+
</body>
29+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4+
<%@ page import="java.util.*"%>
5+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
6+
<html>
7+
<head>
8+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9+
<title>Insert title here</title>
10+
</head>
11+
<body>
12+
<%
13+
/*定义集合 */
14+
List all = new ArrayList();
15+
all.add("www");
16+
all.add("Crazy");
17+
all.add("java");
18+
pageContext.setAttribute("ref", all);
19+
%>
20+
<h3>
21+
输出全部:
22+
<c:forEach items="${ref}" var="mem">
23+
${mem}
24+
</c:forEach>
25+
</h3>
26+
</body>
27+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5+
<html>
6+
<head>
7+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8+
<title>Insert title here</title>
9+
</head>
10+
<body>
11+
<c:set var="info" value="www.crazyjava.cn" scope="request"/>
12+
<c:remove var="info" scope="request"/>
13+
<!--未完 -->
14+
</body>
15+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<%@ page import="com.javaWeb.bean.*"%>
4+
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
5+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
6+
<html>
7+
<head>
8+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9+
<title>Insert title here</title>
10+
</head>
11+
<body>
12+
<%
13+
SimpleInfo sim = new SimpleInfo();
14+
request.setAttribute("simple", sim);
15+
%>
16+
<!--将value的内容设置到simple对象的content属性中 -->
17+
<c:set value="www.crazyjava.cn" target="${simple}" property="content"/>
18+
<h3>属性内容:${simple.content}</h3>
19+
</body>
20+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
4+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5+
<html>
6+
<head>
7+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8+
<title>Insert title here</title>
9+
</head>
10+
<body>
11+
<%
12+
String[] video = { "电影", "电视剧", "动画片", "纪录片" };
13+
request.setAttribute("video", video);
14+
%>
15+
大写转小写:I LOVE CHINA &nbsp;&nbsp;${fn:toLowerCase("I LOVE CHINA")}
16+
<br /> 取长度:I LOVE CHINA的长度为:${fn:length("I LOVE CHINA")}
17+
<br />
18+
19+
</body>
20+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
4+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5+
<html>
6+
<head>
7+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8+
<title>Insert title here</title>
9+
</head>
10+
<body>
11+
<jsp:useBean id="date" class="java.util.Date" />
12+
<fmt:formatDate value="${date}" />
13+
<br>
14+
<fmt:formatDate value="${date}" pattern="yyyy/MM/dd HH:mm:ss:sss" />
15+
</body>
16+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5+
<html>
6+
<head>
7+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8+
<title>Insert title here</title>
9+
</head>
10+
<body>
11+
userName:${param.userName}
12+
<%-- passWord:${param.password} --%>
13+
password:${param.password}
14+
</body>
15+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8"
2+
pageEncoding="UTF-8"%>
3+
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5+
<html>
6+
<head>
7+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8+
<title>Insert title here</title>
9+
</head>
10+
<body>
11+
<c:redirect url="redirect2.jsp">
12+
<c:param name="userName" value="wangwu" />
13+
<c:param name="password" value="123456" />
14+
</c:redirect>
15+
</body>
16+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.javaWeb.bean;
2+
3+
public class SimpleInfo {
4+
private String content;
5+
6+
public String getContent() {
7+
return content;
8+
}
9+
10+
public void setContent(String content) {
11+
this.content = content;
12+
}
13+
14+
}

0 commit comments

Comments
 (0)