实现MVC登录,界面未完善
This commit is contained in:
24
skic/.classpath
Normal file
24
skic/.classpath
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?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/JavaSE-1.7">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="owner.project.facets" value="java"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="com.genuitec.runtime.library/com.genuitec.generic_7.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="con" path="com.genuitec.runtime.library/com.genuitec.jstl_1.2.2">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="org.eclipse.jst.component.dependency" value="WEB-INF/lib"/>
|
||||||
|
<attribute name="owner.project.facets" value="jst.web.jstl"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/mysql-connector-java-5.1.45-bin.jar"/>
|
||||||
|
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
|
||||||
|
</classpath>
|
||||||
36
skic/.project
Normal file
36
skic/.project
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>skic</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>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</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
skic/.settings/.jsdtscope
Normal file
12
skic/.settings/.jsdtscope
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="WebRoot"/>
|
||||||
|
<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
skic/.settings/org.eclipse.jdt.core.prefs
Normal file
7
skic/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
8
skic/.settings/org.eclipse.wst.common.component
Normal file
8
skic/.settings/org.eclipse.wst.common.component
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
|
<wb-module deploy-name="grda1238">
|
||||||
|
<wb-resource deploy-path="/" source-path="/WebRoot" tag="defaultRootSource"/>
|
||||||
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
|
||||||
|
<property name="java-output-path" value="/grda1238/WebRoot/WEB-INF/classes"/>
|
||||||
|
<property name="context-root" value="grda1238"/>
|
||||||
|
</wb-module>
|
||||||
|
</project-modules>
|
||||||
11
skic/.settings/org.eclipse.wst.common.project.facet.core.xml
Normal file
11
skic/.settings/org.eclipse.wst.common.project.facet.core.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<faceted-project>
|
||||||
|
<runtime name="com.genuitec.runtime.generic.jee70"/>
|
||||||
|
<fixed facet="jst.web"/>
|
||||||
|
<fixed facet="java"/>
|
||||||
|
<fixed facet="wst.jsdt.web"/>
|
||||||
|
<installed facet="java" version="1.7"/>
|
||||||
|
<installed facet="jst.web" version="3.1"/>
|
||||||
|
<installed facet="jst.web.jstl" version="1.2.2"/>
|
||||||
|
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||||
|
</faceted-project>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
|
||||||
1
skic/.settings/org.eclipse.wst.jsdt.ui.superType.name
Normal file
1
skic/.settings/org.eclipse.wst.jsdt.ui.superType.name
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Window
|
||||||
3
skic/WebRoot/META-INF/MANIFEST.MF
Normal file
3
skic/WebRoot/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Class-Path:
|
||||||
|
|
||||||
1
skic/WebRoot/WEB-INF/classes/.gitignore
vendored
Normal file
1
skic/WebRoot/WEB-INF/classes/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/com/
|
||||||
4
skic/WebRoot/WEB-INF/classes/dbconfig.properties
Normal file
4
skic/WebRoot/WEB-INF/classes/dbconfig.properties
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
driver=com.mysql.jdbc.Driver
|
||||||
|
db_url=jdbc\:mysql\://localhost\:3306/db_skic?useUnicode\=true&characterEncoding\=utf-8&useSSL\=true
|
||||||
|
user=skic
|
||||||
|
password=bed58b36
|
||||||
BIN
skic/WebRoot/WEB-INF/lib/mysql-connector-java-5.1.45-bin.jar
Normal file
BIN
skic/WebRoot/WEB-INF/lib/mysql-connector-java-5.1.45-bin.jar
Normal file
Binary file not shown.
42
skic/WebRoot/WEB-INF/web.xml
Normal file
42
skic/WebRoot/WEB-INF/web.xml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?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_3_1.xsd" id="WebApp_ID" version="3.1">
|
||||||
|
<display-name>Scorpion king Information consulting company</display-name>
|
||||||
|
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>CheckLoginServlet</servlet-name>
|
||||||
|
<servlet-class>com.skic.servlet.CheckLoginServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>CheckLoginServlet</servlet-name>
|
||||||
|
<url-pattern>/CheckLoginServlet</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>CheckRegisterServlet</servlet-name>
|
||||||
|
<servlet-class>com.skic.servlet.CheckRegisterServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>CheckRegisterServlet</servlet-name>
|
||||||
|
<url-pattern>/CheckRegisterServlet</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<filter-name>vipPermissionFilter</filter-name>
|
||||||
|
<filter-class>com.skic.filter.AdminPermissionFilter</filter-class>
|
||||||
|
</filter>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>vipPermissionFilter</filter-name>
|
||||||
|
<url-pattern>/adminPage/*</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
|
</web-app>
|
||||||
28
skic/WebRoot/adminPage/adminJsp.jsp
Normal file
28
skic/WebRoot/adminPage/adminJsp.jsp
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
|
||||||
|
<%
|
||||||
|
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 'adminJsp.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">
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
This is admin JSP page. <br>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
29
skic/WebRoot/homepage.jsp
Normal file
29
skic/WebRoot/homepage.jsp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
|
||||||
|
<%
|
||||||
|
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>主页</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">
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
欢迎访问主页
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
26
skic/WebRoot/index.jsp
Normal file
26
skic/WebRoot/index.jsp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
|
||||||
|
<%
|
||||||
|
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 'index.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">
|
||||||
|
-->
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<%response.sendRedirect("login.jsp"); %>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
121
skic/WebRoot/login.jsp
Normal file
121
skic/WebRoot/login.jsp
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
|
||||||
|
<%
|
||||||
|
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>登录</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">
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h2>登录个人档案系统</h2>
|
||||||
|
<form action="<%=request.getContextPath()%>/CheckLoginServlet"
|
||||||
|
method="post" name="loginTest">
|
||||||
|
用户名<input type="text" name="userName"><br>
|
||||||
|
密码<input
|
||||||
|
type="password" name="passWord"><br> <input type="submit"
|
||||||
|
value="提交"> <input type="reset" value="重置"><br>
|
||||||
|
<a href="register.jsp">注册</a>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html> --%>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
|
||||||
|
|
||||||
|
<title>skic用户注册</title>
|
||||||
|
<!-- <link rel="stylesheet" type="text/css" href="css/normalize.css" /> -->
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/css/materialize.min.css">
|
||||||
|
<style type="text/css">
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
html {
|
||||||
|
display: table;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
display: table-cell;
|
||||||
|
vertical-align: middle;
|
||||||
|
color:#404d5b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.margin {
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-panel{ min-width:350px;}
|
||||||
|
</style>
|
||||||
|
<!--[if IE]>
|
||||||
|
<script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="login-page" class="row">
|
||||||
|
<div class="col s12 z-depth-6 card-panel">
|
||||||
|
<form class="login-form" action="<%=request.getContextPath()%>/CheckLoginServlet" method="post" name="loginSkic">
|
||||||
|
<div class="row">
|
||||||
|
<div class="input-field col s12 center">
|
||||||
|
<img src="http://w3lessons.info/logo.png" alt="" class="responsive-img valign profile-image-login">
|
||||||
|
<p class="center login-form-text">Welcome to skic</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row margin">
|
||||||
|
<div class="input-field col s12">
|
||||||
|
<i class="mdi-social-person-outline prefix"></i>
|
||||||
|
<input class="validate" name="userName" type="text">
|
||||||
|
<label for="email" data-error="wrong" data-success="right" class="center-align">UserName</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row margin">
|
||||||
|
<div class="input-field col s12">
|
||||||
|
<i class="mdi-action-lock-outline prefix"></i>
|
||||||
|
<input name="passWord" type="password">
|
||||||
|
<label for="password">Password</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="input-field col s12 m12 l12 login-text">
|
||||||
|
<input type="checkbox" id="remember-me" />
|
||||||
|
<label for="remember-me">Remember me</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="input-field col s12">
|
||||||
|
<a href="index.html" class="btn waves-effect waves-light col s12">Login</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="input-field col s6 m6 l6">
|
||||||
|
<p class="margin medium-small"><a href="register.html">Register</a></p>
|
||||||
|
</div>
|
||||||
|
<div class="input-field col s6 m6 l6">
|
||||||
|
<p class="margin right-align medium-small"><a href="forgot-password.html">Forgot password?</a></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<!--materialize js-->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/js/materialize.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
44
skic/WebRoot/messagePage/error.jsp
Normal file
44
skic/WebRoot/messagePage/error.jsp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
|
||||||
|
<%
|
||||||
|
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>错误页面</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">
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="message">
|
||||||
|
提示信息 <br>
|
||||||
|
<%
|
||||||
|
Object obj = request.getAttribute("msg");
|
||||||
|
if (obj != null) {
|
||||||
|
out.println(obj.toString());
|
||||||
|
} else {
|
||||||
|
out.println("无");
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
</div>
|
||||||
|
您提交的信息为
|
||||||
|
<br> 用户名:<%=request.getParameter("userName")%><br>
|
||||||
|
密码:<%=request.getParameter("passWord1")%><br>
|
||||||
|
<a href="<%=request.getAttribute("RedirctURL")%>">返回登录</a>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
43
skic/WebRoot/messagePage/messageShow.jsp
Normal file
43
skic/WebRoot/messagePage/messageShow.jsp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
|
||||||
|
<%
|
||||||
|
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 'messageShow.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">
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="message">提示信息
|
||||||
|
<br>
|
||||||
|
<%
|
||||||
|
Object obj = request.getAttribute("msg");
|
||||||
|
if (obj != null) {
|
||||||
|
out.println(obj.toString());
|
||||||
|
} else {
|
||||||
|
out.println("无");
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
</div>
|
||||||
|
您提交的信息为
|
||||||
|
<br> 用户名:<%=request.getParameter("userName")%><br>
|
||||||
|
密码:<%=request.getParameter("passWord1")%><br>
|
||||||
|
<a href="<%=request.getAttribute("RedirctURL")%>"><%=request.getAttribute("Redirct")%></a>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
39
skic/WebRoot/register.jsp
Normal file
39
skic/WebRoot/register.jsp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
|
||||||
|
<%
|
||||||
|
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>注册</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">
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h2>注册skic</h2>
|
||||||
|
<form action="<%=request.getContextPath()%>/CheckRegisterServlet"
|
||||||
|
method="post" name="loginTest">
|
||||||
|
用户名<input type="text" name="userName"><br> 姓名<input
|
||||||
|
type="text" name="realName"><br> 密码<input
|
||||||
|
type="password" name="passWord1"><br> 确认密码<input
|
||||||
|
type="password" name="passWord2"><br> 邮箱<input
|
||||||
|
type="email" name="email"><br> 电话<input type="tel"
|
||||||
|
name="tel"><br> <input type="submit" value="注册">
|
||||||
|
<input type="reset" value="重置">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
18
skic/src/com/skic/DAO/UserDAO.java
Normal file
18
skic/src/com/skic/DAO/UserDAO.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package com.skic.DAO;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
|
||||||
|
import com.skic.DTO.UserDTO;
|
||||||
|
|
||||||
|
public interface UserDAO {
|
||||||
|
public int insert(Connection conn, UserDTO user) throws SQLException;
|
||||||
|
|
||||||
|
public boolean update(Connection conn, long PK, UserDTO user) throws SQLException;
|
||||||
|
|
||||||
|
public boolean delete(Connection conn, UserDTO user) throws SQLException;
|
||||||
|
|
||||||
|
public ResultSet select(Connection conn, UserDTO user) throws SQLException;
|
||||||
|
|
||||||
|
public ResultSet showAll(Connection conn, UserDTO user) throws SQLException;
|
||||||
|
|
||||||
|
}
|
||||||
77
skic/src/com/skic/DAO/impl/UserDAOimpl.java
Normal file
77
skic/src/com/skic/DAO/impl/UserDAOimpl.java
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
package com.skic.DAO.impl;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import com.skic.DAO.UserDAO;
|
||||||
|
import com.skic.DTO.UserDTO;
|
||||||
|
|
||||||
|
public class UserDAOimpl implements UserDAO {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insert(Connection conn, UserDTO user) throws SQLException {
|
||||||
|
PreparedStatement pre = conn.prepareStatement(""
|
||||||
|
+ "INSERT INTO tb_skicvip (col_userName, col_realName, col_passWord, col_email, col_phoneNum, col_vipFlag, col_adminFlag, col_rootFlag) VALUES(?,?,?,?,?,?,?,?)");
|
||||||
|
pre.setString(1, user.getUserName());
|
||||||
|
pre.setString(2, user.getRealName());
|
||||||
|
pre.setString(3, user.getPassword());
|
||||||
|
pre.setString(4, user.getEmail());
|
||||||
|
pre.setString(5, user.getPhoneNum());
|
||||||
|
pre.setInt(6, user.getVip());
|
||||||
|
pre.setInt(7, user.getAdmin());
|
||||||
|
pre.setInt(8, user.getRoot());
|
||||||
|
int res = pre.executeUpdate();
|
||||||
|
System.out.println("tb_skicvip"+res+"条记录");
|
||||||
|
pre.close();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(Connection conn, long PK, UserDTO user) throws SQLException {
|
||||||
|
PreparedStatement pre = conn.prepareStatement(""
|
||||||
|
+ "UPDATE tb_skicvip SET col_userName=?,col_realName=?,col_passWord=?,col_email=?,col_phoneNum=?,col_vipFlag=?,col_adminFlag=?,col_rootFlag=? WHERE col_id=?");
|
||||||
|
String col_id = String.valueOf(PK);
|
||||||
|
pre.setString(1, user.getUserName());
|
||||||
|
pre.setString(2, user.getRealName());
|
||||||
|
pre.setString(3, user.getPassword());
|
||||||
|
pre.setString(4, user.getEmail());
|
||||||
|
pre.setString(5, user.getPhoneNum());
|
||||||
|
pre.setInt(6, user.getVip());
|
||||||
|
pre.setInt(7, user.getAdmin());
|
||||||
|
pre.setInt(8, user.getRoot());
|
||||||
|
pre.setString(9, col_id);
|
||||||
|
boolean res = pre.execute();
|
||||||
|
pre.close();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(Connection conn, UserDTO user) throws SQLException {
|
||||||
|
PreparedStatement pre = conn.prepareStatement("DELETE FROM tb_skicvip WHERE col_userName=?");
|
||||||
|
pre.setString(1, user.getUserName());
|
||||||
|
boolean res = pre.execute();
|
||||||
|
pre.close();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultSet select(Connection conn, UserDTO user) throws SQLException {
|
||||||
|
PreparedStatement pre = conn
|
||||||
|
.prepareStatement(
|
||||||
|
"SELECT col_userName, col_realName, col_passWord, col_email, col_phoneNum, col_vipFlag, col_adminFlag, col_rootFlag FROM tb_skicvip WHERE col_userName=? AND col_passWord=?");
|
||||||
|
pre.setString(1, user.getUserName());
|
||||||
|
pre.setString(2, user.getPassword());
|
||||||
|
return pre.executeQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultSet showAll(Connection conn, UserDTO user) throws SQLException {
|
||||||
|
PreparedStatement pre = conn
|
||||||
|
.prepareStatement(
|
||||||
|
"SELECT col_userName, col_realName, col_passWord, col_email, col_phoneNum, col_vipFlag, col_adminFlag, col_rootFlag FROM tb_skicvip");
|
||||||
|
return pre.executeQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
14
skic/src/com/skic/DTO/PrimaryKey.java
Normal file
14
skic/src/com/skic/DTO/PrimaryKey.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package com.skic.DTO;
|
||||||
|
|
||||||
|
public class PrimaryKey {
|
||||||
|
protected long PK;
|
||||||
|
|
||||||
|
public long getPK() {
|
||||||
|
return PK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPK(long pK) {
|
||||||
|
PK = pK;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
87
skic/src/com/skic/DTO/UserDTO.java
Normal file
87
skic/src/com/skic/DTO/UserDTO.java
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
package com.skic.DTO;
|
||||||
|
/**
|
||||||
|
* tb_skicvip.DTO
|
||||||
|
* @author 11860
|
||||||
|
*字段含义参考数据字典
|
||||||
|
*/
|
||||||
|
public class UserDTO extends PrimaryKey {
|
||||||
|
private String userName;
|
||||||
|
private String password;
|
||||||
|
private String realName;
|
||||||
|
private String email;
|
||||||
|
private String phoneNum;
|
||||||
|
private int vip = 0;
|
||||||
|
private int admin = 0;
|
||||||
|
private int root = 0;
|
||||||
|
|
||||||
|
public String getRealName() {
|
||||||
|
return realName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRealName(String realName) {
|
||||||
|
this.realName = realName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhoneNum() {
|
||||||
|
return phoneNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhoneNum(String phoneNum) {
|
||||||
|
this.phoneNum = phoneNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVip() {
|
||||||
|
return vip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVip(int vip) {
|
||||||
|
this.vip = vip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAdmin() {
|
||||||
|
return admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdmin(int admin) {
|
||||||
|
this.admin = admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRoot() {
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoot(int root) {
|
||||||
|
this.root = root;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "UserDTO [userName=" + userName + ", password=" + password + ", realName=" + realName + ", email="
|
||||||
|
+ email + ", phoneNum=" + phoneNum + ", PK=" + PK + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
72
skic/src/com/skic/filter/AdminPermissionFilter.java
Normal file
72
skic/src/com/skic/filter/AdminPermissionFilter.java
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
package com.skic.filter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.servlet.Filter;
|
||||||
|
import javax.servlet.FilterChain;
|
||||||
|
import javax.servlet.FilterConfig;
|
||||||
|
import javax.servlet.RequestDispatcher;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.ServletRequest;
|
||||||
|
import javax.servlet.ServletResponse;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
public class AdminPermissionFilter implements Filter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
public AdminPermissionFilter() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Filter#destroy()
|
||||||
|
*/
|
||||||
|
public void destroy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
|
||||||
|
*/
|
||||||
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||||
|
HttpServletRequest req = (HttpServletRequest)request;
|
||||||
|
HttpServletResponse resp = (HttpServletResponse)response;
|
||||||
|
String servletPathString = req.getServletPath();
|
||||||
|
HttpSession session = req.getSession();
|
||||||
|
String flag = (String) session.getAttribute("adminflag");
|
||||||
|
if (servletPathString!= null
|
||||||
|
&&(servletPathString.equals("/login.jsp"))||
|
||||||
|
(servletPathString.equals("/homepage.jsp"))||
|
||||||
|
(servletPathString.equalsIgnoreCase("/CheckLoginServlet"))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
chain.doFilter(request, response);
|
||||||
|
}else {
|
||||||
|
if (flag!= null && flag.equals("admin")) {
|
||||||
|
chain.doFilter(request, response);
|
||||||
|
}else if (flag!=null&&flag.equals("error")) {
|
||||||
|
req.setAttribute("msg", "你不是管理员!");
|
||||||
|
req.setAttribute("return_uri", servletPathString);
|
||||||
|
RequestDispatcher rd = req.getRequestDispatcher("/homepage.jsp");
|
||||||
|
rd.forward(req, resp);
|
||||||
|
}else {
|
||||||
|
req.setAttribute("msg", "您尚未登录");
|
||||||
|
req.setAttribute("return_uri", servletPathString);
|
||||||
|
RequestDispatcher rd = req.getRequestDispatcher("/login.jsp");
|
||||||
|
rd.forward(req, resp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Filter#init(FilterConfig)
|
||||||
|
*/
|
||||||
|
public void init(FilterConfig fConfig) throws ServletException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
48
skic/src/com/skic/service/CheckLoginService.java
Normal file
48
skic/src/com/skic/service/CheckLoginService.java
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package com.skic.service;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
|
||||||
|
import com.skic.DAO.UserDAO;
|
||||||
|
import com.skic.DAO.impl.UserDAOimpl;
|
||||||
|
import com.skic.DTO.UserDTO;
|
||||||
|
import com.skic.util.ConnectionFactory;
|
||||||
|
|
||||||
|
public class CheckLoginService {
|
||||||
|
private UserDAO userdao = new UserDAOimpl();
|
||||||
|
|
||||||
|
public boolean CheckUser(UserDTO USERDTO) {
|
||||||
|
Connection conn = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
conn = ConnectionFactory.getInstance().makeConnection();
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
ResultSet resultSet1 = userdao.select(conn, USERDTO);//调用数据库查询
|
||||||
|
conn.commit();
|
||||||
|
if (resultSet1.next()) {//查询账号是否存在
|
||||||
|
return true;
|
||||||
|
}else {
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("获取查询结果失败");
|
||||||
|
e.printStackTrace();
|
||||||
|
try {
|
||||||
|
System.out.println("更新数据失败,数据库回滚");
|
||||||
|
conn.rollback();
|
||||||
|
} catch (SQLException e1) {
|
||||||
|
System.out.println("数据库回滚失败");
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (conn != null) {
|
||||||
|
try {
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("数据库关闭失败");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
58
skic/src/com/skic/service/CheckRegisterService.java
Normal file
58
skic/src/com/skic/service/CheckRegisterService.java
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
package com.skic.service;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
|
||||||
|
import com.skic.DAO.UserDAO;
|
||||||
|
import com.skic.DAO.impl.UserDAOimpl;
|
||||||
|
import com.skic.DTO.UserDTO;
|
||||||
|
import com.skic.util.ConnectionFactory;
|
||||||
|
|
||||||
|
public class CheckRegisterService {
|
||||||
|
private UserDAO userdao = new UserDAOimpl();
|
||||||
|
|
||||||
|
public boolean AddUser(UserDTO USERDTO) {
|
||||||
|
Connection conn = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
conn = ConnectionFactory.getInstance().makeConnection();
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
System.out.println(USERDTO.getUserName());
|
||||||
|
System.out.println(USERDTO.getPassword());
|
||||||
|
int status = userdao.insert(conn, USERDTO);
|
||||||
|
conn.commit();
|
||||||
|
if (status!=0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/*ResultSet resultSet1 = userdao.select(conn, USERDTO);
|
||||||
|
int id_log = userdao.insertLogName(conn, USERDTO);
|
||||||
|
System.out.println("id_log="+id_log);
|
||||||
|
if (resultSet1.next()) {
|
||||||
|
userdao.updateLogStatus(conn, USERDTO, "成功",id_log);
|
||||||
|
return true;
|
||||||
|
}else {
|
||||||
|
userdao.updateLogStatus(conn, USERDTO, "失败",id_log);
|
||||||
|
}*/
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("插入数据失败");
|
||||||
|
e.printStackTrace();
|
||||||
|
try {
|
||||||
|
System.out.println("更新数据失败,数据库回滚");
|
||||||
|
conn.rollback();
|
||||||
|
} catch (SQLException e1) {
|
||||||
|
System.out.println("数据库回滚失败");
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (conn != null) {
|
||||||
|
try {
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("数据库关闭失败");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
69
skic/src/com/skic/servlet/CheckLoginServlet.java
Normal file
69
skic/src/com/skic/servlet/CheckLoginServlet.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package com.skic.servlet;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.servlet.RequestDispatcher;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.skic.DTO.UserDTO;
|
||||||
|
import com.skic.service.CheckLoginService;
|
||||||
|
|
||||||
|
public class CheckLoginServlet extends HttpServlet {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -477275992604759935L;
|
||||||
|
private CheckLoginService cks = new CheckLoginService();
|
||||||
|
|
||||||
|
public CheckLoginServlet() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
super.destroy(); // Just puts "destroy" string in log
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
doPost(request, response);
|
||||||
|
}
|
||||||
|
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
request.setCharacterEncoding("utf-8");
|
||||||
|
String userName = request.getParameter("userName");
|
||||||
|
String passWord = request.getParameter("passWord");
|
||||||
|
RequestDispatcher rd = null;
|
||||||
|
String forwardString = null;
|
||||||
|
if (userName==null||passWord==null) {
|
||||||
|
request.setAttribute("msg", "用户名或密码为空");
|
||||||
|
rd = request.getRequestDispatcher("/messagePage/error.jsp");
|
||||||
|
rd.forward(request, response);
|
||||||
|
}else {
|
||||||
|
UserDTO user = new UserDTO();
|
||||||
|
user.setUserName(userName);
|
||||||
|
user.setPassword(passWord);
|
||||||
|
boolean bool = cks.CheckUser(user);
|
||||||
|
System.out.println(bool);
|
||||||
|
if (bool) {
|
||||||
|
request.setAttribute("msg", "登录成功");
|
||||||
|
request.setAttribute("RedirctURL", "homepage.jsp");
|
||||||
|
request.setAttribute("Redirct", "前往主页");
|
||||||
|
//forwardString = "/messagePage/messageShow.jsp";
|
||||||
|
}else {
|
||||||
|
request.setAttribute("msg", "账号不存在,请注册");
|
||||||
|
request.setAttribute("RedirctURL", "register.jsp");
|
||||||
|
request.setAttribute("Redirct", "返回登录");
|
||||||
|
}
|
||||||
|
forwardString = "/messagePage/messageShow.jsp";
|
||||||
|
rd = request.getRequestDispatcher(forwardString);
|
||||||
|
rd.forward(request, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() throws ServletException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
75
skic/src/com/skic/servlet/CheckRegisterServlet.java
Normal file
75
skic/src/com/skic/servlet/CheckRegisterServlet.java
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
package com.skic.servlet;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.servlet.RequestDispatcher;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.skic.DTO.UserDTO;
|
||||||
|
import com.skic.service.CheckRegisterService;;
|
||||||
|
|
||||||
|
public class CheckRegisterServlet extends HttpServlet {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 8438869886327574209L;
|
||||||
|
private CheckRegisterService crs = new CheckRegisterService();
|
||||||
|
|
||||||
|
public CheckRegisterServlet() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
super.destroy(); // Just puts "destroy" string in log
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
doPost(request, response);
|
||||||
|
}
|
||||||
|
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
request.setCharacterEncoding("utf-8");
|
||||||
|
String userName = request.getParameter("userName");
|
||||||
|
String realName = request.getParameter("realName");
|
||||||
|
String email = request.getParameter("email");
|
||||||
|
String passWord = request.getParameter("passWord1");
|
||||||
|
String tel = request.getParameter("tel");
|
||||||
|
RequestDispatcher rd = null;
|
||||||
|
String forwardString = null;
|
||||||
|
if (userName==null||passWord==null) {
|
||||||
|
request.setAttribute("msg", "用户名或密码为空");
|
||||||
|
rd = request.getRequestDispatcher("/messagePage/error.jsp");
|
||||||
|
rd.forward(request, response);
|
||||||
|
}else {
|
||||||
|
UserDTO user = new UserDTO();
|
||||||
|
user.setUserName(userName);
|
||||||
|
user.setPassword(passWord);
|
||||||
|
user.setRealName(realName);
|
||||||
|
user.setEmail(email);;
|
||||||
|
user.setPhoneNum(tel);
|
||||||
|
boolean bool = crs.AddUser(user);
|
||||||
|
System.out.println(bool);
|
||||||
|
if (bool) {
|
||||||
|
request.setAttribute("msg", "注册成功,请登录");
|
||||||
|
request.setAttribute("RedirctURL", "login.jsp");
|
||||||
|
request.setAttribute("Redirct", "前往登录");
|
||||||
|
//forwardString = "/messagePage/messageShow.jsp";
|
||||||
|
}else {
|
||||||
|
request.setAttribute("msg", "账号已存在,请重新注册");
|
||||||
|
request.setAttribute("RedirctURL", "register.jsp");
|
||||||
|
request.setAttribute("Redirct", "重新注册");
|
||||||
|
}
|
||||||
|
forwardString = "/messagePage/messageShow.jsp";
|
||||||
|
rd = request.getRequestDispatcher(forwardString);
|
||||||
|
rd.forward(request, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() throws ServletException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
48
skic/src/com/skic/util/ConnectionFactory.java
Normal file
48
skic/src/com/skic/util/ConnectionFactory.java
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package com.skic.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class ConnectionFactory {
|
||||||
|
private static String driverString;
|
||||||
|
private static String dburlString;
|
||||||
|
private static String userString;
|
||||||
|
private static String pasString;
|
||||||
|
private static final ConnectionFactory FACTORY = new ConnectionFactory();
|
||||||
|
private Connection conn;
|
||||||
|
static {
|
||||||
|
Properties prop = new Properties();
|
||||||
|
try {
|
||||||
|
InputStream in = ConnectionFactory.class.getClassLoader().getResourceAsStream("dbconfig.properties");
|
||||||
|
prop.load(in);
|
||||||
|
} catch (IOException e1) {
|
||||||
|
System.out.println("读取Properties文件出错");
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
driverString = prop.getProperty("driver");
|
||||||
|
dburlString = prop.getProperty("db_url");
|
||||||
|
userString = prop.getProperty("user");
|
||||||
|
pasString = prop.getProperty("password");
|
||||||
|
}
|
||||||
|
|
||||||
|
private ConnectionFactory() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConnectionFactory getInstance() {
|
||||||
|
return FACTORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Connection makeConnection() {
|
||||||
|
try {
|
||||||
|
Class.forName(driverString);
|
||||||
|
conn = DriverManager.getConnection(dburlString, userString, pasString);
|
||||||
|
} catch (Exception e2) {
|
||||||
|
System.out.println("数据库驱动加载失败");
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
|
}
|
||||||
14
skic/src/com/skic/util/ConnectionFactoryTestConn.java
Normal file
14
skic/src/com/skic/util/ConnectionFactoryTestConn.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package com.skic.util;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
|
||||||
|
public class ConnectionFactoryTestConn {
|
||||||
|
public static void main(String[] args) throws Exception{
|
||||||
|
Connection conn = ConnectionFactory.getInstance().makeConnection();
|
||||||
|
if (conn.getAutoCommit()) {
|
||||||
|
System.out.println("数据库连接正常");
|
||||||
|
}else {
|
||||||
|
System.out.println("数据库无法连接");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
4
skic/src/dbconfig.properties
Normal file
4
skic/src/dbconfig.properties
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
driver=com.mysql.jdbc.Driver
|
||||||
|
db_url=jdbc\:mysql\://localhost\:3306/db_skic?useUnicode\=true&characterEncoding\=utf-8&useSSL\=true
|
||||||
|
user=skic
|
||||||
|
password=bed58b36
|
||||||
Reference in New Issue
Block a user