Skip to content

Commit 4423c32

Browse files
committed
Signed-off-by: chenhaoxiang <[email protected]>
1 parent fdc58c4 commit 4423c32

33 files changed

+524
-1
lines changed

Database-support-package/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
���ݿ�֧�ְ�
1+
数据库支持包

myPagesDividedWeb/.classpath

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_6_CONTAINER"/>
6+
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
7+
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
8+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
9+
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
10+
</classpath>

myPagesDividedWeb/.mymetadata

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-module
3+
type="WEB"
4+
name="myPagesDividedWeb"
5+
id="myeclipse.1471319255861"
6+
context-root="/myPagesDividedWeb"
7+
j2ee-spec="6.0"
8+
archive="myPagesDividedWeb.war">
9+
<attributes>
10+
<attribute name="webrootdir" value="WebRoot" />
11+
</attributes>
12+
</project-module>
13+

myPagesDividedWeb/.project

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>myPagesDividedWeb</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.jdt.core.javabuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
<buildCommand>
29+
<name>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</name>
30+
<arguments>
31+
</arguments>
32+
</buildCommand>
33+
<buildCommand>
34+
<name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</name>
35+
<arguments>
36+
</arguments>
37+
</buildCommand>
38+
<buildCommand>
39+
<name>org.eclipse.wst.validation.validationbuilder</name>
40+
<arguments>
41+
</arguments>
42+
</buildCommand>
43+
<buildCommand>
44+
<name>com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder</name>
45+
<arguments>
46+
</arguments>
47+
</buildCommand>
48+
</buildSpec>
49+
<natures>
50+
<nature>com.genuitec.eclipse.ast.deploy.core.deploymentnature</nature>
51+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
52+
<nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>
53+
<nature>org.eclipse.jdt.core.javanature</nature>
54+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
55+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
56+
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
57+
</natures>
58+
</projectDescription>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="WebRoot"/>
4+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
6+
<attributes>
7+
<attribute name="hide" value="true"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
11+
<classpathentry kind="output" path=""/>
12+
</classpath>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Tue Aug 16 11:47:36 CST 2016
2+
eclipse.preferences.version=1
3+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5+
org.eclipse.jdt.core.compiler.compliance=1.6
6+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8+
org.eclipse.jdt.core.compiler.source=1.6
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-modules id="moduleCoreId" project-version="1.5.0">
3+
<wb-module deploy-name="myPagesDividedWeb">
4+
<wb-resource deploy-path="/" source-path="/WebRoot"/>
5+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
6+
<property name="context-root" value="/myPagesDividedWeb"/>
7+
<property name="java-output-path" value="/myPagesDividedWeb/WebRoot/WEB-INF/classes"/>
8+
</wb-module>
9+
</project-modules>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<faceted-project>
3+
<fixed facet="wst.jsdt.web"/>
4+
<installed facet="java" version="1.6"/>
5+
<installed facet="jst.web" version="3.0"/>
6+
<installed facet="wst.jsdt.web" version="1.0"/>
7+
</faceted-project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Window

myPagesDividedWeb/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
JavaWeb分页技术1
2+
3+
分页,是一种将所有数据分段展示给用户的技术.用户每次看到的不 是全部数据,而是其中的一部分,如果在其中没有找到自己想要的内容,用户可以通过指定页码或是点上/下一页的方式进行翻页。
4+
5+
本例演示静态分页,也就是先设置好每页显示10行,再根据总行数,来算出总页数,将所有页数的页号都显示出来。
6+
7+
8+
相关算法(技术):
9+
10+
总行数(num): select count(1) from stud;
11+
12+
每页显示的行数(n): 固定值---已知的一个常量
13+
14+
页数: pageSize= num/n + (num%n==0)?0:1
15+
16+
当前页号: currentPage
17+
18+
当前要显示的页面数据的起始行号和终止行号
19+
startN: (currentPage-1)*pageSize
20+
21+
如何显示从startN开始的pageSize条记录
22+
select * from stud limit startN, pageSize;
23+
24+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<c3p0-config>
2+
<!-- 默认配置,如果没有指定则使用这个配置 -->
3+
<default-config>
4+
<property name="driverClass">com.mysql.jdbc.Driver</property>
5+
<property name="jdbcUrl">
6+
<![CDATA[jdbc:mysql://127.0.0.1:3306/hncu?useUnicode=true&characterEncoding=UTF-8]]>
7+
</property>
8+
<property name="user">root</property>
9+
<property name="password">1234</property>
10+
<!-- 初始化池大小 -->
11+
<property name="initialPoolSize">2</property>
12+
<!-- 最大空闲时间 -->
13+
<property name="maxIdleTime">30</property>
14+
<!-- 最多有多少个连接 -->
15+
<property name="maxPoolSize">10</property>
16+
<!-- 最少几个连接 -->
17+
<property name="minPoolSize">2</property>
18+
<!-- 每次最多可以执行多少个批处理语句 -->
19+
<property name="maxStatements">50</property>
20+
</default-config>
21+
<!-- 命名的配置 -->
22+
<named-config name="demo">
23+
<property name="driverClass">com.mysql.jdbc.Driver</property>
24+
<property name="jdbcUrl"><![CDATA[jdbc:mysql://127.0.0.1:3306/hncu?useUnicode=true&characterEncoding=UTF-8]]></property>
25+
<property name="user">root</property>
26+
<property name="password">1234</property>
27+
<property name="acquireIncrement">5</property><!-- 如果池中数据连接不够时一次增长多少个 -->
28+
<property name="initialPoolSize">100</property>
29+
<property name="minPoolSize">50</property>
30+
<property name="maxPoolSize">1000</property>
31+
<property name="maxStatements">0</property>
32+
<property name="maxStatementsPerConnection">5</property> <!-- he's important, but there's only one of him -->
33+
</named-config>
34+
</c3p0-config>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app version="3.0"
3+
xmlns="http://java.sun.com/xml/ns/javaee"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
6+
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
7+
<display-name></display-name>
8+
<servlet>
9+
<servlet-name>PageServlet</servlet-name>
10+
<servlet-class>cn.hncu.servlet.PageServlet</servlet-class>
11+
</servlet>
12+
13+
<servlet-mapping>
14+
<servlet-name>PageServlet</servlet-name>
15+
<url-pattern>/PageServlet</url-pattern>
16+
<!-- 这里的/代表项目根目录下 -->
17+
</servlet-mapping>
18+
<welcome-file-list>
19+
<welcome-file>index.jsp</welcome-file>
20+
</welcome-file-list>
21+
</web-app>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
body{
2+
text-align: center;
3+
}
4+
table{
5+
border: 1px solid blue;
6+
width: 500px;
7+
border-collapse: collapse;/*为表格设置合并边框模型:*/
8+
margin: auto;
9+
}
10+
td,th,tr{
11+
border: 1px solid blue;
12+
}
13+
.pc{
14+
width: 30px;
15+
height: 30px;
16+
border: 1px solid #e1e2e3;
17+
border-top-color: rgb(225, 226, 227);
18+
border-top-style: solid;
19+
border-top-width: 1px;
20+
border-right-color: rgb(225, 226, 227);
21+
border-right-style: solid;
22+
border-right-width: 1px;
23+
border-bottom-color: rgb(225, 226, 227);
24+
border-bottom-style: solid;
25+
border-bottom-width: 1px;
26+
border-left-color: rgb(225, 226, 227);
27+
border-left-style: solid;
28+
border-left-width: 1px;
29+
}
30+
.now {
31+
display: block;
32+
}

myPagesDividedWeb/WebRoot/index.jsp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
2+
3+
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5+
<html>
6+
<head>
7+
</head>
8+
9+
<body>
10+
<c:redirect url="/PageServlet"></c:redirect>
11+
</body>
12+
</html>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
2+
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
3+
4+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5+
<html>
6+
<head>
7+
<title>演示数据分页显示</title>
8+
<link rel="stylesheet" href="<c:url value='/css/table.css' />" />
9+
10+
<script type="text/javascript">
11+
function sub(obj){
12+
window.location.href="<c:url value='/PageServlet?page=' />"+obj.value;
13+
}
14+
</script>
15+
16+
</head>
17+
18+
<body>
19+
<h3>当前页的内容:</h3>
20+
<table>
21+
<tr><th>学号</th><th>姓名</th></tr>
22+
<c:forEach items="${result.datas}" var="map">
23+
<tr>
24+
<td>${map.id}</td>
25+
<td>${map.name}</td>
26+
</tr>
27+
</c:forEach>
28+
</table>
29+
30+
31+
<c:if test="${result.currentPage!=1}">
32+
<span class="pc">
33+
<a href='<c:url value="/PageServlet?page=${result.currentPage-1}"></c:url>'>上一页</a>
34+
</span>
35+
</c:if>
36+
37+
&nbsp;&nbsp;
38+
<c:forEach begin="1" end="${result.pageCount}" var="idx">
39+
<c:if test="${idx==result.currentPage}" var="isNow">
40+
<span class=now>${idx}</span>
41+
</c:if>
42+
<c:if test="${!isNow }">
43+
<span class="pc">
44+
<a href='<c:url value="/PageServlet?page=${idx}"></c:url>'>${idx}</a>
45+
</span>
46+
</c:if>
47+
&nbsp;&nbsp;
48+
</c:forEach>
49+
50+
<c:if test="${result.currentPage!=result.pageCount}">
51+
<span class="pc">
52+
<a href="<c:url value='/PageServlet?page=${result.currentPage+1}'></c:url>">下一页</a>
53+
</span>
54+
</c:if>
55+
<br/><br/>
56+
57+
<!-- 复选框 -->
58+
<select onchange="sub(this)">
59+
<c:forEach begin="1" end="${result.pageCount}" var="idx">
60+
<option <c:if test="${idx==result.currentPage}">selected="selected"</c:if> value="${idx}" >
61+
${idx}
62+
</option>
63+
</c:forEach>
64+
</select>
65+
66+
</body>
67+
</html>

myPagesDividedWeb/src/c3p0-config.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<c3p0-config>
2+
<!-- 默认配置,如果没有指定则使用这个配置 -->
3+
<default-config>
4+
<property name="driverClass">com.mysql.jdbc.Driver</property>
5+
<property name="jdbcUrl">
6+
<![CDATA[jdbc:mysql://127.0.0.1:3306/hncu?useUnicode=true&characterEncoding=UTF-8]]>
7+
</property>
8+
<property name="user">root</property>
9+
<property name="password">1234</property>
10+
<!-- 初始化池大小 -->
11+
<property name="initialPoolSize">2</property>
12+
<!-- 最大空闲时间 -->
13+
<property name="maxIdleTime">30</property>
14+
<!-- 最多有多少个连接 -->
15+
<property name="maxPoolSize">10</property>
16+
<!-- 最少几个连接 -->
17+
<property name="minPoolSize">2</property>
18+
<!-- 每次最多可以执行多少个批处理语句 -->
19+
<property name="maxStatements">50</property>
20+
</default-config>
21+
<!-- 命名的配置 -->
22+
<named-config name="demo">
23+
<property name="driverClass">com.mysql.jdbc.Driver</property>
24+
<property name="jdbcUrl"><![CDATA[jdbc:mysql://127.0.0.1:3306/hncu?useUnicode=true&characterEncoding=UTF-8]]></property>
25+
<property name="user">root</property>
26+
<property name="password">1234</property>
27+
<property name="acquireIncrement">5</property><!-- 如果池中数据连接不够时一次增长多少个 -->
28+
<property name="initialPoolSize">100</property>
29+
<property name="minPoolSize">50</property>
30+
<property name="maxPoolSize">1000</property>
31+
<property name="maxStatements">0</property>
32+
<property name="maxStatementsPerConnection">5</property> <!-- he's important, but there's only one of him -->
33+
</named-config>
34+
</c3p0-config>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package cn.hncu.dao;
2+
3+
import java.sql.SQLException;
4+
import java.util.Map;
5+
6+
public interface IPageDAO {
7+
public Map<String, Object> query(Integer pageNo) throws NumberFormatException, SQLException;
8+
}

0 commit comments

Comments
 (0)