包括相關的Jar包,css和tld文件
2.將extremecomponents-1.0.1.jar放到web-inf/lib下面
3.將下載的images文件夾放到WebRoot目錄下面
4.將下載的extremecomponents.css放到WebRoot目錄下面的css文件夾下
5.新建一個extremecomponents的測試頁面ExtremeCompomentTest_1.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.extremecomponents.org" prefix="ec" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'ExtremeCompomentTest_1.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" type="text/css" href="<%=path%>/css/extremecomponents.css">
</head>
<%
java.util.List presidents = new java.util.ArrayList();
java.util.Map president = new java.util.HashMap();
president.put("name", "George Washington");
president.put("nickname", "Father of His Country");
president.put("term", "1789-1797");
presidents.add(president);
president = new java.util.HashMap();
president.put("name", "John Adams");
president.put("nickname", "Atlas of Independence");
president.put("term", "1797-1801");
presidents.add(president);
president = new java.util.HashMap();
president.put("name", "Thomas Jefferson");
president.put("nickname", "Man of the People, Sage of Monticello");
president.put("term", "1801-09");
presidents.add(president);
president = new java.util.HashMap();
president.put("name", "James Madison");
president.put("nickname", "Father of the Constitution");
president.put("term", "1809-17");
presidents.add(president);
president = new java.util.HashMap();
president.put("name", "James Monroe");
president.put("nickname", "The Last Cocked Hat, Era-of-Good-Feelings President");
president.put("term", "1817-25");
presidents.add(president);
president = new java.util.HashMap();
president.put("name", "John Adams");
president.put("nickname", "Old Man Eloquent");
president.put("term", "1825-29");
presidents.add(president);
request.setAttribute("pres", presidents); %>
<body>
This is my JSP page. <br>
<ec:table items="pres"
title="ExtremeCompomentTest"
action="${pageContext.request.contextPath}/ExtremeCompomentTest_1.jsp"
imagePath="${pageContext.request.contextPath}/images/table/*.gif"
rowsDisplayed="2"
>
<ec:row>
<ec:column property="name"></ec:column>
<ec:column property="nickname"></ec:column>
<ec:column property="term"></ec:column>
</ec:row>
</ec:table>
</body>
</html>
6.運行頁面的效果如下:
[img]http://dl.iteye.com/upload/attachment/479351/3cd0c545-e023-3c4a-9a39-cb0bc9e75b52.png[/img]
7.對測試的Jsp頁面-ExtremeCompomentTest_1.jsp進行分析:
1)在頁面中要添加<%@ taglib uri="http://www.extremecomponents.org" prefix="ec" %>
2)在頁面中添加<link rel="stylesheet" type="text/css" href="<%=path%>/css/extremecomponents.css">的Css配置信息
3)創建一個HashMap,並且將presidents放在request中
<%
java.util.List presidents = new java.util.ArrayList();
java.util.Map president = new java.util.HashMap();
president.put("name", "George Washington");
president.put("nickname", "Father of His Country");
president.put("term", "1789-1797");
presidents.add(president);
president = new java.util.HashMap();
president.put("name", "John Adams");
president.put("nickname", "Atlas of Independence");
president.put("term", "1797-1801");
presidents.add(president);
president = new java.util.HashMap();
president.put("name", "Thomas Jefferson");
president.put("nickname", "Man of the People, Sage of Monticello");
president.put("term", "1801-09");
presidents.add(president);
president = new java.util.HashMap();
president.put("name", "James Madison");
president.put("nickname", "Father of the Constitution");
president.put("term", "1809-17");
presidents.add(president);
president = new java.util.HashMap();
president.put("name", "James Monroe");
president.put("nickname", "The Last Cocked Hat, Era-of-Good-Feelings President");
president.put("term", "1817-25");
presidents.add(president);
president = new java.util.HashMap();
president.put("name", "John Adams");
president.put("nickname", "Old Man Eloquent");
president.put("term", "1825-29");
presidents.add(president);
request.setAttribute("pres", presidents); %>
4)對於body中的數據
<ec:table items="pres"
title="ExtremeCompomentTest"
action="${pageContext.request.contextPath}/ExtremeCompomentTest_1.jsp"
imagePath="${pageContext.request.contextPath}/images/table/*.gif"
rowsDisplayed="2"
>
<ec:row>
<ec:column property="name"></ec:column>
<ec:column property="nickname"></ec:column>
<ec:column property="term"></ec:column>
</ec:row>
</ec:table>
其中的items="pres"是數據源,title="ExtremeCompomentTest"是table的頭信息,imagePath是圖片的路徑,rowsDisplayed是每頁顯示的記錄數目,action是點擊下頁,前頁時要跳轉的頁面。
參考文檔:[url]http://blogold.chinaunix.net/u/7893/showart_426623.html[/url]