1801010630 6 роки тому
коміт
0cd5ce334f

+ 22 - 0
YDH/.classpath

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_181">
+		<attributes>
+			<attribute name="owner.project.facets" value="java"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v9.0">
+		<attributes>
+			<attribute name="owner.project.facets" value="jst.web"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+	<classpathentry kind="lib" path="K:/mysql-connector-java-8.0.15/mysql-connector-java-8.0.15.jar">
+		<attributes>
+			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>

+ 31 - 0
YDH/.project

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>YDH</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.common.project.facet.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+	</natures>
+</projectDescription>

+ 12 - 0
YDH/.settings/.jsdtscope

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="WebContent"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+		<attributes>
+			<attribute name="hide" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+	<classpathentry kind="output" path=""/>
+</classpath>

+ 7 - 0
YDH/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8

+ 8 - 0
YDH/.settings/org.eclipse.wst.common.component

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
+    <wb-module deploy-name="YDH">
+        <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
+        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+        <property name="context-root" value="YDH"/>
+        <property name="java-output-path" value="/YDH/build/classes"/>
+    </wb-module>
+</project-modules>

+ 10 - 0
YDH/.settings/org.eclipse.wst.common.project.facet.core.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+  <runtime name="Apache Tomcat v9.0"/>
+  <fixed facet="wst.jsdt.web"/>
+  <fixed facet="java"/>
+  <fixed facet="jst.web"/>
+  <installed facet="java" version="1.8"/>
+  <installed facet="jst.web" version="4.0"/>
+  <installed facet="wst.jsdt.web" version="1.0"/>
+</faceted-project>

+ 1 - 0
YDH/.settings/org.eclipse.wst.jsdt.ui.superType.container

@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary

+ 1 - 0
YDH/.settings/org.eclipse.wst.jsdt.ui.superType.name

@@ -0,0 +1 @@
+Window

+ 3 - 0
YDH/WebContent/META-INF/MANIFEST.MF

@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+

+ 13 - 0
YDH/WebContent/META-INF/context.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context>
+<Resource name="jdbc/ydh"
+          auth="Container"
+          type="javax.sql.DataSource"
+          maxActive="30"
+          maxIdle="10"
+          maxWait="10000" 
+          username="root" 
+          password="123456"
+          driverClassName="com.mysql.cj.jdbc.Driver"
+          url="jdbc:mysql://localhost:3306/ydh?serverTimezone=UTC&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=utf8"/>
+</Context>

+ 25 - 0
YDH/WebContent/Register.jsp

@@ -0,0 +1,25 @@
+<%//注册页面 %>
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+	pageEncoding="UTF-8"%>
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>Insert title here</title>
+</head>
+<body>
+	<h3>注册页面</h3>
+	<form action="Register_test.jsp" method="post" enctype="mutipart/form-data">
+		username:<input type="text" name="username">
+		<p>
+			class:<input type="text" name="class">
+		<p>
+			password:<input type="password" name="password">
+		<p>
+			sex: <input type="radio" name="sex" value="男" checked />男 <input
+				type="radio" name="sex" value="女" />女
+		<p>
+			<input type="submit" value="注册">
+	</form>
+</body>
+</html>

+ 45 - 0
YDH/WebContent/Register_test.jsp

@@ -0,0 +1,45 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+	pageEncoding="UTF-8"%>
+<%@ page import="java.sql.*,javax.sql.*,javax.naming.*,java.util.*"%>
+<%
+	Connection connect = null;
+	boolean existence;
+	request.setCharacterEncoding("UTF-8");
+	String username =request.getParameter("username");
+	String password =request.getParameter("password");
+	String sex =request.getParameter("sex");
+	String clas =request.getParameter("class");
+	if (username == null && password == null) {
+		out.print("注册的账号或密码不能为空,请重新输入");
+%>
+<a href="Register.jsp">请重新注册</a>
+<%
+	}
+	
+	try {
+		InitialContext ctx = new InitialContext();
+		DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/ydh");
+		connect = ds.getConnection();
+		Statement stmt = connect.createStatement();
+		ResultSet rs = stmt.executeQuery(
+				"select * from register where uname='" + username + "' and upassword='" + password + "'");
+		if (rs.next()) {
+			existence = true;
+		} else {
+			existence = false;
+		}
+		if (existence) {
+			connect.close();
+			out.print("该用户以存在,请重新创建!");
+			out.clear();
+			out = pageContext.pushBody();
+		} else {
+			stmt.execute("insert into register value('"+username+"','"+password+"','"+clas+"','"+sex+"')");
+			connect.close();
+			request.setAttribute("msg","注册成功");
+			request.getRequestDispatcher("login.jsp").forward(request, response);
+		}
+	} catch (Exception e) {
+		e.printStackTrace();
+	}
+%>

+ 18 - 0
YDH/WebContent/WEB-INF/web.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
+  <display-name>YDH</display-name>
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>index.htm</welcome-file>
+    <welcome-file>index.jsp</welcome-file>
+    <welcome-file>default.html</welcome-file>
+    <welcome-file>default.htm</welcome-file>
+    <welcome-file>default.jsp</welcome-file>
+  </welcome-file-list>
+    <resource-ref>
+    <description>DB Connection</description>
+    <res-ref-name>jdbc/ydh</res-ref-name>
+    <res-type>javax.sql.DataSource</res-type>
+    <res-auth>Container</res-auth>
+  </resource-ref>
+</web-app>

+ 163 - 0
YDH/WebContent/baoming.jsp

@@ -0,0 +1,163 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>校运会报名</title>
+<style type="text/css">
+    *{ margin: 0;
+       padding: 0;
+    }
+    body{
+    	background: linear-gradient(to top right, white 0%, skyblue 98%,blue 100%);
+    	font-family: "宋体";
+    }
+	h1{
+	    color: white;
+	    margin-left: 20px;
+	    margin-top: 15px;
+	}
+	h4{ color: white;
+		margin-left: 20px;
+	}
+	.a{
+		height: 20px;
+		width: 95%;
+		background: linear-gradient(to bottom, white 25%, gray 100%);
+		margin-top: 10px;
+		margin-left: 20px;
+	}
+	.b{
+		height: 600px;
+		width: 330px;
+		margin: 10px 0 0 15px;
+		line-height: 20px;
+		color: green;
+	}
+	.d{
+		height: 630px;
+		width: 450px;
+		margin: -590px 0 0 375px;
+	}
+	form{height: 600px;
+		 width: 550px;
+	}
+	table{margin:30px 0 0 70px;
+		  line-height: 50px;
+	}
+</style>
+</head>
+<body>
+<h1>
+	深圳信息职业技术学院校运会报名
+</h1>
+<h4>Shenzhen Vocational and Technical College of Information Enrollment for School Games</h4>
+<div class="a"></div>
+<div class="b"></div>
+<div class="c"></div>
+<div class="d">
+	<form action="enter.do" method="post">
+		<fieldset style="width: 450px;height: 600px;">
+			<legend>报名信息</legend>
+			<table border="0" cellspacing="0" cellpadding="20">
+				<tr>
+					<td>
+						姓名:<input type="text" name="name">
+					</td>
+				</tr>
+				<tr>
+					<td>
+						学号:<input type="text" name="num">
+					</td>
+				</tr>
+				<tr>
+					<td>
+						班级:<input type="text" name="class0">
+					</td>
+				</tr>
+				<tr>
+					<td>
+						性别:
+					<input type="radio" name="sex" value="男">男
+					<input type="radio" name="sex" value="女">女
+					</td>
+				</tr>
+				<tr>
+					<td>
+						联系电话:<input type="text" name="telephone">
+					</td>
+				</tr>
+				<tr>
+					<td>
+						请选择报名组别:<select name="group" id="province" runat="server" onchange="selectprovince(this);" style=" width:95px;"></select>
+					</td>
+				</tr>
+				<tr>
+					<td>
+						请选择报名项目:<select name="project" id="city" runat="server" style=" width:95px;"></select>
+					</td>
+				</tr>
+				<tr>
+					<td>
+						<input type="submit" value="提交报名信息">
+					</td>
+				</tr>
+			</table>
+		</fieldset>
+	</form>
+	<script type="text/javascript">
+    var list1 = new Array;
+    var list2 = new Array;
+    list1[list1.length] = "学生组";
+    list1[list1.length] = "教工青年组";
+	list1[list1.length] = "教工中年组";
+	list1[list1.length] = "教工老年组";
+    list2[list2.length] = new Array("100米", "200米", "400米", "800米", "1500米", "3000米", "4×100米接力", "跳高","三级跳远", "铅球");
+	list2[list2.length] = new Array("100米", "800米", "跳高","跳远","铅球");
+	list2[list2.length] = new Array("60米", "800米", "跳高","跳远","铅球");
+	list2[list2.length] = new Array("60米", "50米托球跑","跳远","铅球");
+    var ddlProvince = document.getElementById("province");
+    var ddlCity = document.getElementById("city");
+    for(var i =0;i<list1.length; i++)
+    {
+        var option = document.createElement("option");
+        option.appendChild(document.createTextNode(list1[i]));
+        option.value = list1[i];
+        ddlProvince.appendChild(option);
+        //city initialize
+        var firstprovince = list2[0];
+        for (var j = 0; j < firstprovince.length; j++) {
+            var optioncity = document.createElement("option");
+            optioncity.appendChild(document.createTextNode(firstprovince[j]));
+            optioncity.value = firstprovince[j];
+            ddlCity.appendChild(optioncity);
+        }
+    }
+    function indexof(obj,value)
+    {
+        var k=0;
+        for(;k<obj.length;k++)
+        {
+            if(obj[k] == value)
+            return k;
+        }
+        return k;
+    }
+    function selectprovince(obj) {
+        ddlCity.options.length = 0;//clear
+        var index = indexof(list1,obj.value);
+        var list2element = list2[index];
+        for(var i =0;i<list2element.length; i++)
+        {
+            var option = document.createElement("option");
+            option.appendChild(document.createTextNode(list2element[i]));
+            option.value = list2element[i];
+            ddlCity.appendChild(option);
+        }
+    }
+	</script>
+</div>
+
+</body>
+</html>

+ 43 - 0
YDH/WebContent/login.jsp

@@ -0,0 +1,43 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+	pageEncoding="UTF-8"%>
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>Insert title here</title>
+</head>
+<body>
+	<%  String msg=(String)request.getAttribute("msg");
+		Cookie[] cookies = request.getCookies();
+		String cUser = "";
+		String cPassword = "";
+		if (cookies != null) {
+			int x = cookies.length;
+			for (int i = 0; i < x; i++) {
+				Cookie cookie = cookies[i];
+				if ("username".equals(cookie.getName())) {
+					cUser = cookie.getValue();
+				}
+				if ("password".equals(cookie.getName())) {
+					cPassword = cookie.getValue();
+				}
+			}
+		}
+	%>
+	<font color="red"><%=msg==null?"":msg %></font>
+	<form action="login_test.jsp" method="post">
+		username:<input type="text" name="username" value="<%=cUser%>">
+		<p>
+			password:<input type="password" name="password"
+				value="<%=cPassword%>">
+		<p>
+			记住密码: <input type="checkbox" value="1" name="flag">
+		<p>
+		<a href="Register.jsp">注册</a>
+		<p>
+			<input type="submit" value="登录">
+			<input type="reset" value="清空">
+	</form>
+
+</body>
+</html>