package com.zl.base;
import org.apache.commons.dbutils.QueryRunner;
import com.zl.util.DButils;
/**
* 操作业务的定义
*
* @author 丢了风筝的线
*
* @see 2020年1月9日
*/
public interface BaseDao<T> {
static final QueryRunner QR = DButils.getQueryRunner();
// 更据id去查询
T selectById(int id);
// 添加信息
int add(T t);
// 根据id删除信息
int del(int id);
// 修改信息
int update(T t);
}
package com.zl.base;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servelt的基类
*
* @author 丢了风筝的线
*
* @see 2020年1月9日
*/
@WebServlet("/ServletBase")
public class BaseServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest rq, HttpServletResponse rp) throws ServletException, IOException {
// 设置字符编码集
rq.setCharacterEncoding("utf-8");
rp.setContentType("text/html;charset=utf-8");
// 获取页面请求的方法类型
String method = rq.getParameter("method");
// 根据方法名调用指定的方法
Class clazz = this.getClass();
Method m;
try {
m = clazz.getMethod(method, HttpServletRequest.class, HttpServletResponse.class);
m.invoke(this, rq, rp);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
package com.zl.base.impl;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.zl.base.BaseServlet;
/**
* 数据库的操作Servlet
*
* @author 丢了风筝的线
*
* @see 2020年1月9日
*/
@WebServlet("/DBServlet")
public class DBServlet extends BaseServlet {
private static final long serialVersionUID = 1L;
// 添加
public void add(HttpServletRequest rq, HttpServletResponse rp) {
//
}
// 删除
public void delete(HttpServletRequest rq, HttpServletResponse rp) {
}
// 修改
public void update(HttpServletRequest rq, HttpServletResponse rp) {
}
// 查询
public void find(HttpServletRequest rq, HttpServletResponse rp) {
}
}
package com.zl.dao;
import java.util.List;
import com.zl.base.BaseDao;
import com.zl.entity.Goods;
/**
-
商品操作定义
-
@author 丢了风筝的线
-
@see 2020年1月9日
*/
public interface GoodCRUDDao extends BaseDao {// 查询所有额商品
List selectAll();
}
package com.zl.dao;
import java.util.List;
import com.zl.base.BaseDao;
import com.zl.entity.Goodstype;
/**
* 商品操作定义
*
* @author 丢了风筝的线
*
* @see 2020年1月9日
*/
public interface GoodsTypeDao extends BaseDao<Goodstype> {
// 查询所有的商品类别
public List<Goodstype> selectAll();
}
package com.zl.dao;
import com.zl.base.BaseDao;
import com.zl.entity.User;
/**
* 登录时使用到的方法的定义
*
* @author 丢了风筝的线
*
* @see 2020年1月7日
*/
public interface UserDao extends BaseDao<User> {
User selectByNameAndPwd(String name, String password);
}
package com.zl.daoimpl;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import com.zl.dao.GoodCRUDDao;
import com.zl.entity.Goods;
/**
-
商品操作实现类
-
@author 丢了风筝的线
-
@see 2020年1月9日
*/
public class GoodsDaoImpl implements GoodCRUDDao {
// 查询所有商品信息
@Override
public List selectAll() {
String sql = “select * from goods”;
List list = null;
try {
list = QR.query(sql, new BeanListHandler(Goods.class));} catch (SQLException e) { e.printStackTrace(); } return list;
}
@Override
public Goods selectById(int id) {
String sql = “select * from goods where gid = ?”;
Goods g = null;
try {
g = QR.query(sql, new BeanHandler(Goods.class), id);
} catch (SQLException e) {e.printStackTrace(); } return g;
}
@Override
public int add(Goods g) {
String sql = “insert into goods(gname,price,gdesc,createDate,typename)values(?,?,?,?,?)”;
int n = 0;
try {
n = QR.update(sql, g.getGname(), g.getPrice(), g.getGdesc(), g.getCreateDate(), g.getTypename());} catch (SQLException e) { e.printStackTrace(); } return n;
}
@Override
public int del(int id) {
String sql = “delete from goods where gid=?”;
int n = 0;
try {
n = QR.update(sql, id);
} catch (SQLException e) {e.printStackTrace(); } return n;
}
@Override
public int update(Goods g) {
String sql = “update goods set gname=?,price=?,gdesc=?,createDate=? where gid=?”;
int n = 0;
try {
n = QR.update(sql, g.getGname(), g.getPrice(), g.getGdesc(), g.getCreateDate(), g.getGid());
} catch (SQLException e) {e.printStackTrace(); } return n;
}
}
package com.zl.daoimpl;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import com.zl.dao.GoodsTypeDao;
import com.zl.entity.Goodstype;
/**
* 商品操作实现类
*
* @author 丢了风筝的线
*
* @see 2020年1月9日
*/
public class GoodsTypeDaoImpl implements GoodsTypeDao {
@Override
public Goodstype selectById(int id) {
return null;
}
// 添加商品类型
@Override
public int add(Goodstype gt) {
String sql = "insert into goodtype set typename=?";
int n = 0;
try {
n = QR.update(sql, gt.getTypename());
} catch (SQLException e) {
e.printStackTrace();
}
return n;
}
@Override
public int del(int id) {
return 0;
}
@Override
public int update(Goodstype t) {
return 0;
}
@Override
public List<Goodstype> selectAll() {
List<Goodstype> typeList = null;
String sql = "select * from goodtype";
try {
typeList = QR.query(sql, new BeanListHandler<Goodstype>(Goodstype.class));
} catch (SQLException e) {
e.printStackTrace();
}
return typeList;
}
}
package com.zl.daoimpl;
import java.sql.SQLException;
import org.apache.commons.dbutils.handlers.BeanHandler;
import com.zl.dao.UserDao;
import com.zl.entity.User;
/**
* 登录功能的具体实现
*
* @author 丢了风筝的线
*
* @see 2020年1月7日
*/
public class UserDaoImpl implements UserDao {
// 通过用户id查询
@Override
public User selectById(int id) {
return null;
}
// 添加用户信息
@Override
public int add(User u) {
String sql = "insert into user(name,password)values(?,?)";
int n = 0;
try {
n = QR.update(sql, u.getName(), u.getPassword());
} catch (SQLException e) {
e.printStackTrace();
}
return n;
}
// 删除用户信息
@Override
public int del(int id) {
return 0;
}
// 修改用户的信息
@Override
public int update(User u) {
return 0;
}
// 根据name和password查询
@Override
public User selectByNameAndPwd(String name, String password) {
String sql = "select * from user where name=? and password=?";
User u = null;
try {
u = QR.query(sql, new BeanHandler<User>(User.class), name, password);
} catch (SQLException e) {
e.printStackTrace();
}
return u;
}
}
package com.zl.entity;
/**
* 商品实体类
*
* @author 丢了风筝的线
*
* @see 2020年1月9日
*/
public class Goods {
private int gid;
private String gname;
private double price;
private String gdesc;
private String createDate;
private String typename;
public Goods() {
super();
}
public String getTypename() {
return typename;
}
public void setTypename(String typename) {
this.typename = typename;
}
public Goods(int gid, String gname, double price, String gdesc, String createDate, String typename) {
super();
this.gid = gid;
this.gname = gname;
this.price = price;
this.gdesc = gdesc;
this.createDate = createDate;
this.typename = typename;
}
public Goods(String gname, double price, String gdesc, String createDate, String typename) {
super();
this.gname = gname;
this.price = price;
this.gdesc = gdesc;
this.createDate = createDate;
this.typename = typename;
}
public int getGid() {
return gid;
}
public void setGid(int gid) {
this.gid = gid;
}
public String getGname() {
return gname;
}
public void setGname(String gname) {
this.gname = gname;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getGdesc() {
return gdesc;
}
public void setGdesc(String gdesc) {
this.gdesc = gdesc;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
@Override
public String toString() {
return "Goods [gid=" + gid + ", gname=" + gname + ", price=" + price + ", gdesc=" + gdesc + ", createDate="
+ createDate + ", typename=" + typename + "]";
}
}
package com.zl.entity;
/**
* 商品类型类
*
* @author 丢了风筝的线
*
* @see 2020年1月12日
*/
public class Goodstype {
private int id;
private String typename;
public Goodstype() {
super();
}
public Goodstype(int id, String typename) {
super();
this.id = id;
this.typename = typename;
}
public Goodstype(String typename) {
this.typename = typename;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTypename() {
return typename;
}
public void setTypename(String typename) {
this.typename = typename;
}
@Override
public String toString() {
return "Goodstype [id=" + id + ", typename=" + typename + "]";
}
}
package com.zl.entity;
/**
* 学生实体类
*
* @author 丢了风筝的线
*
* @see 2020年1月7日
*/
public class User {
private String id;
private String name;
private String password;
public User() {
}
public User(String name, String password) {
this.name = name;
this.password = password;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "Studnet [id=" + id + ", name=" + name + ", password=" + password + "]";
}
}
package com.zl.service;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import com.zl.base.BaseServlet;
import com.zl.dao.GoodCRUDDao;
import com.zl.dao.GoodsTypeDao;
import com.zl.daoimpl.GoodsDaoImpl;
import com.zl.daoimpl.GoodsTypeDaoImpl;
import com.zl.entity.Goods;
import com.zl.entity.Goodstype;
/**
*
* @author 丢了风筝的线
*
* @see 2020年1月10日
*/
@WebServlet("/goodsCRUD")
public class GoodsService extends BaseServlet {
GoodCRUDDao gd = new GoodsDaoImpl();
GoodsTypeDao dta = new GoodsTypeDaoImpl();
// 展示商品
public void show(HttpServletRequest rq, HttpServletResponse rp) throws ServletException, IOException {
List<Goods> list = gd.selectAll();
if (list.size() > 0) {
// 绑定list数据,发送到商品操作页面
rq.setAttribute("goodlist", list);
rq.getRequestDispatcher("goodsCRUD.jsp").forward(rq, rp);
} else {
rp.getWriter().print("当前没有商品");
}
}
// 删除商品
public void del(HttpServletRequest rq, HttpServletResponse rp) throws ServletException, IOException {
int n = gd.del(Integer.parseInt(rq.getParameter("gid")));
if (n > 0) {
show(rq, rp);
} else {
rp.getWriter().print("删除失败!");
rp.sendRedirect("goodsCRUD?method=show");
}
}
// 添加商品
public void add(HttpServletRequest rq, HttpServletResponse rp) throws ServletException, IOException {
Goods g = new Goods();
try {
Map<String, String[]> map = rq.getParameterMap();
if (!map.isEmpty()) {
rp.getWriter().print("添加失败");
} else {
BeanUtils.populate(g, map);
int n = gd.add(g);
if (n > 0) {
rp.sendRedirect("goodsCRUD?method=show");
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
// 获取商品的所有类型
public void getGoodstype(HttpServletRequest rq, HttpServletResponse rp) throws ServletException, IOException {
List<Goodstype> typelist = dta.selectAll();
if (typelist != null) {
rq.setAttribute("typelist", typelist);
rq.getRequestDispatcher("addGoods.jsp").forward(rq, rp);
}
}
// 展示要修改的商品的信息
public void showUpdate(HttpServletRequest rq, HttpServletResponse rp) throws ServletException, IOException {
int gid = Integer.parseInt(rq.getParameter("gid"));
Goods g = gd.selectById(gid);
if (g != null) {
rq.setAttribute("good", g);
rq.getRequestDispatcher("goodUpdate.jsp").forward(rq, rp);
}
}
// 修改商品的信息
public void update(HttpServletRequest rq, HttpServletResponse rp) throws ServletException, IOException {
Goods g = new Goods();
try {
BeanUtils.populate(g, rq.getParameterMap());
int n = gd.update(g);
rp.sendRedirect("goodsCRUD?method=show");
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
package com.zl.service;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import com.zl.base.BaseServlet;
import com.zl.dao.GoodsTypeDao;
import com.zl.daoimpl.GoodsTypeDaoImpl;
import com.zl.entity.Goodstype;
/**
*
* @author 丢了风筝的线
*
* @see 2020年1月10日
*/
@WebServlet("/goodsTypeAdd")
public class GoodsTypeService extends BaseServlet {
GoodsTypeDao gtd = new GoodsTypeDaoImpl();
// 添加商品
public void addType(HttpServletRequest rq, HttpServletResponse rp) throws ServletException, IOException {
Goodstype gt = new Goodstype();
try {
BeanUtils.populate(gt, rq.getParameterMap());
int n = gtd.add(gt);
if (n > 0) {
rp.getWriter().print("添加成功!");
} else {
rp.getWriter().print("添加失败!");
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
package com.zl.service;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.zl.base.BaseServlet;
import com.zl.dao.GoodCRUDDao;
import com.zl.dao.UserDao;
import com.zl.daoimpl.GoodsDaoImpl;
import com.zl.daoimpl.UserDaoImpl;
import com.zl.entity.User;
/**
* 登录
*
* @author 丢了风筝的线
*
* @see 2020年1月9日
*/
@WebServlet("/login")
public class LoginService extends BaseServlet {
UserDao ud = new UserDaoImpl();
GoodCRUDDao gd = new GoodsDaoImpl();
public void onlogin(HttpServletRequest rq, HttpServletResponse rp) throws ServletException, IOException {
String name = rq.getParameter("name");
String password = rq.getParameter("password");
User user = ud.selectByNameAndPwd(name, password);
// 获取session
HttpSession session = rq.getSession();
// 绑定数据
session.setAttribute("userinfo", user);
if (user != null) {
rp.sendRedirect("index.html");
} else {
rp.sendRedirect("register.html");
}
}
}
package com.zl.service;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import com.zl.base.BaseServlet;
import com.zl.dao.UserDao;
import com.zl.daoimpl.UserDaoImpl;
import com.zl.entity.User;
/**
* 注册
*
* @author 丢了风筝的线
*
* @see 2020年1月9日
*/
@WebServlet("/register")
public class RegisterService extends BaseServlet {
UserDao ud = new UserDaoImpl();
public void onregister(HttpServletRequest rq, HttpServletResponse rp) throws ServletException, IOException {
User user = new User();
try {
BeanUtils.populate(user, rq.getParameterMap());
int n = ud.add(user);
if (n > 0) {
rp.getWriter().print("<script>location.href='sikp.html'</script>");
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
package com.zl.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 日期转换工具
*
* @author 丢了风筝的线
*
* @see 2020年1月10日
*/
public class DateTransUtil {
public static Date getDate(String date) {
// 规定日期的格式
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date d = null;
try {
// 将日期字符串转换为日期
d = df.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return d;
}
}
package com.zl.util;
import javax.sql.DataSource;
import org.apache.commons.dbutils.QueryRunner;
import com.mchange.v2.c3p0.ComboPooledDataSource;
/**
* 数据库操作的工具类
*
* @author 丢了风筝的线
*
* @see 2020年1月6日
*/
public class DButils {
static DataSource ds;
// 1、创建数据源
static {
ds = new ComboPooledDataSource();
}
private DButils() {
}
// 2、通过连接创建执行器
public static QueryRunner getQueryRunner() {
return new QueryRunner(ds);
}
}
<!-- c3p0数据库连接池的配置文件 -->
<c3p0-config>
<!-- 默认配置 -->
<default-config>
<!-- 数据库的驱动 -->
<property name="driverClass">com.mysql.jdbc.Driver</property>
<!-- 数据库的链接路径 -->
<property name="jdbcUrl">jdbc:mysql:///stu</property>
<!-- 数据库的用户名 -->
<property name="user">root</property>
<!-- 密码 -->
<property name="password">123</property>
<!-- 空闲链接测试周期 -->
<property name="idleConnectionTestPeriod">30</property>
<!-- 最大的空闲时间 -->
<property name="maxIdleTime">30</property>
<!-- 检查链接超时 -->
<property name="checkout">30000</property>
<!-- 连接池初始的大小 -->
<property name="initialPoolSize">10</property>
<!-- 最大的连接数 -->
<property name="maxpoolSize">100</property>
<!-- 最小的连接数 -->
<property name="minPoolSize">10</property>
<!-- 最大的执行器数 -->
<property name="maxStatements">200</property>
</default-config>
</c3p0-config>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.List,com.zl.entity.Goodstype"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加商品页面</title>
</head>
<body>
<center>
<br/><br/><br/><br/><br/>
<form action="goodsCRUD?method=add" method="post">
商品名称:<input type="text" name="gname"/><br/><br/>
商品价格:<input type="text" name="price"/><br/><br/>
商品描述:<input type="text" name="gdesc"/><br/><br/>
生产日期:<input type="text" name="createDate"/><br/><br/>
商品类型: <select name="typename" id="s1">
<%
List<Goodstype> typelist =(List<Goodstype>) request.getAttribute("typelist");
for(Goodstype goodtype:typelist){ %>
<option value=<%=goodtype.getTypename()%>><%=goodtype.getTypename()%></option>
<%}%>
</select><br/><br/>
<input type="submit" value="添加"/>
</form>
</center>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加商品类型</title>
</head>
<body>
<center>
<br/><br/><br/><br/><br/>
<form action="goodsTypeAdd?method=addType" method="post">
商品类型:<input type="text" name="typename"/><br/><br/>
<input type="submit" value="添加"/>
</form>
</center>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.List,com.zl.entity.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品操作页面</title>
</head>
<body>
<%Object obj = session.getAttribute("userinfo");
if(obj!=null){%>
<center>
<br/><br/><br/>
<table width=70% border=1 cellspacing=0 cellpadding=0 style='text-align:center'>
<caption>商品列表</caption>
<tr>
<th>商品编号</th>
<th>商品名称</th>
<th>商品价格</th>
<th>商品描述</th>
<th>生产日期</th>
<th>商品类型</th>
<th>操作</th>
</tr>
<%
List<Goods> list = (List<Goods>)request.getAttribute("goodlist");
for(Goods g :list){%>
<tr>
<td><%=g.getGid() %></td>
<td><%=g.getGname()%></td>
<td><%=g.getPrice()%></td>
<td><%=g.getGdesc() %></td>
<td><%=g.getCreateDate()%></td>
<td><%=g.getTypename()%></td>
<td><a href="goodsCRUD?method=showUpdate&gid=<%=g.getGid()%>">修改</a> | <a href="goodsCRUD?method=del&gid=<%=g.getGid()%>">删除</a></td>
</tr>
<%}%>
<tr>
<td colspan="7"><a href="goodsCRUD?method=getGoodstype">添加</a></td>
</tr>
</table>
</center>
<%}else{
out.print("请先登录");
} %>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>商品管理首页</title>
<style type="text/css">
.header{
height: 50px;
text-align: center;
border-bottom: 2px solid #424242;
}
.middle{
height: 500px;
width: 100%;
background: pink;
}
.middle .left{
float: left;
width: 25%;
height: 500px;
text-align: center;
}
.left a{
display: block;
width: 300px;
height: 50px;
font-size: 18px;
font-weight: 700;
text-decoration: none;
}
.right{
float: right;
width: 75%;
}
</style>
</head>
<body>
<div class="header">
<h1>商品管理系统</h1>
</div>
<div class="middle">
<div class="left">
<br/><br/><br/><br/>
<a href="addGoodType.html" target="inf">添加商品类型</a>
<a href="goodsCRUD?method=show" target="inf">查看所有商品</a>
<a href="goodsCRUD?method=getGoodstype" target="inf">添加商品信息</a>
</div>
<div class="right">
<iframe name="inf" width="100%" height="498" ></iframe>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<style type="text/css">
body{
background:url(images/74.jpg);
}
</style>
</head>
<body>
<center>
<br/><br/><br/><br/><br/><br/>
<form action="login?method=onlogin" method="post">
用户名<input name="name"/><br/><br/><br/>
密 码 <input name="password"/><br/><br/>
<input type="submit" value="登录">
</form>
</center>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>注册页面</title>
<style type="text/css">
body{
background:url(images/74.jpg);
}
</style>
</head>
<body>
<center>
<br/><br/><br/><br/><br/><br/>
<form action="register?method=onregister" method="post">
用户名<input name="name"/><br/><br/><br/>
密 码 <input name="password"/><br/><br/>
<input type="submit" value="提交">
</form>
</center>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>注册登录跳转页面</title>
</head>
<script type="text/javascript">
window.onload = function(){
var i = 5;
setInterval(function(){
i--;
if(i<=0){
location.href="login.html";
}
document.getElementById("sp").innerHTML = i;
},1000);
}
</script>
<body>
<center>
<br><br><br><br><br><br><br><br>
将在<span id="sp">5</span>秒后跳转到<a href="login.html">登录</a>页面
</center>
</body>
</html>