wuheng %!s(int64=2) %!d(string=hai) anos
pai
achega
198447e822
Modificáronse 34 ficheiros con 867 adicións e 0 borrados
  1. 38 0
      day11/src/com/lovecoding/cookie/Cookie1Demo.java
  2. 44 0
      day11/src/com/lovecoding/cookie/CookieDemo.java
  3. 39 0
      day11/src/com/lovecoding/session/SessionDemo.java
  4. BIN=BIN
      day11/web/WEB-INF/lib/el-api.jar
  5. BIN=BIN
      day11/web/WEB-INF/lib/jsp-api.jar
  6. BIN=BIN
      day11/web/WEB-INF/lib/servlet-api.jar
  7. 12 0
      day11/web/WEB-INF/web.xml
  8. 16 0
      day11/web/index.jsp
  9. 69 0
      study/src/com/lovecoding/study/domian/Brand.java
  10. 61 0
      study/src/com/lovecoding/study/domian/User.java
  11. 15 0
      study/src/com/lovecoding/study/mapper/UserMapper.java
  12. 29 0
      study/src/com/lovecoding/study/servlet/TestServlet.java
  13. 83 0
      study/src/com/lovecoding/study/servlet/UserServlet.java
  14. 33 0
      study/src/com/lovecoding/study/utils/MybatisUtils.java
  15. BIN=BIN
      study/web/WEB-INF/lib/el-api.jar
  16. BIN=BIN
      study/web/WEB-INF/lib/jsp-api.jar
  17. BIN=BIN
      study/web/WEB-INF/lib/jstl-1.2.jar
  18. BIN=BIN
      study/web/WEB-INF/lib/mybatis-3.5.5.jar
  19. BIN=BIN
      study/web/WEB-INF/lib/mysql-connector-java-8.0.30.jar
  20. BIN=BIN
      study/web/WEB-INF/lib/protobuf-java-3.19.4.jar
  21. BIN=BIN
      study/web/WEB-INF/lib/servlet-api.jar
  22. BIN=BIN
      study/web/WEB-INF/lib/standard-1.1.2.jar
  23. 22 0
      study/web/WEB-INF/mybatis-config.xml
  24. 6 0
      study/web/WEB-INF/web.xml
  25. 23 0
      study/web/addBrand.html
  26. 26 0
      study/web/brand.jsp
  27. 102 0
      study/web/css/login.css
  28. 146 0
      study/web/css/register.css
  29. BIN=BIN
      study/web/imgs/Desert1.jpg
  30. BIN=BIN
      study/web/imgs/a.jpg
  31. BIN=BIN
      study/web/imgs/reg_bg_min.jpg
  32. 30 0
      study/web/login.jsp
  33. 50 0
      study/web/register.jsp
  34. 23 0
      study/web/update.html

+ 38 - 0
day11/src/com/lovecoding/cookie/Cookie1Demo.java

@@ -0,0 +1,38 @@
+package com.lovecoding.cookie;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLDecoder;
+
+@WebServlet("/cookie/value")
+public class Cookie1Demo extends HttpServlet {
+
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        resp.setCharacterEncoding("utf-8");
+
+        Cookie[] cookies = req.getCookies();
+
+        if ( cookies != null  )
+            for ( Cookie cookie: cookies) {
+
+                System.out.println( "Cookie 名字: " + cookie.getName() );
+
+                if ( cookie.getName().equals("name") ) {
+                    System.out.println( "Cookie Value: " + URLDecoder.decode(cookie.getValue(), "UTF-8"));
+                } else {
+                    System.out.println( "Cookie Value: " + cookie.getValue() );
+                }
+
+
+
+            }
+
+
+    }
+
+}

+ 44 - 0
day11/src/com/lovecoding/cookie/CookieDemo.java

@@ -0,0 +1,44 @@
+package com.lovecoding.cookie;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+
+@WebServlet("/cookie")
+public class CookieDemo extends HttpServlet{
+
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        resp.setCharacterEncoding("utf-8");
+
+        String user = "张三";
+
+        //创建一个cookie
+        Cookie cookie = new Cookie("name", URLEncoder.encode(user, "UTF-8"));
+        //七天后过期
+        cookie.setMaxAge( 60 * 60 * 24 * 7 );
+
+        cookie.setMaxAge( -1 ); //如果是负数  那么就是会话级别
+        cookie.setMaxAge( 0 );  //如果是 0 那么 cookie 直接销毁
+        cookie.setMaxAge( 1 );  //如果设置整数  则按当前时间戳加秒 计算有效期
+
+        //cookie值不能被 JavaScript 读取
+        cookie.setHttpOnly( true ); //会导致cookie登陆的站点跨域登陆失败
+        //cookie.setSecure( true );  //仅适用于 HTTPS
+        //cookie.setDomain( "baidu.com" ); // cookie共享 跨域共享 整个百度都能读
+        //cookie.setDomain( "tieba.baidu.com" ); //pic.baidu.com 就不能读取cookie
+        cookie.setPath("/");  //cookie共享 跨应用共享  / 代表所有应用都能读取 共享
+        //cookie.setPath("/day11_war_exploded");  //只能当前应用下 的 Servlet 能读取cookie
+        //把cookie 设置到 respones 里面
+        resp.addCookie( cookie );
+
+        resp.setContentType("text/html; charset=utf-8");
+
+        resp.getWriter().print(" cookie 设置完成 ");
+    }
+
+}

+ 39 - 0
day11/src/com/lovecoding/session/SessionDemo.java

@@ -0,0 +1,39 @@
+package com.lovecoding.session;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+
+@WebServlet("/session")
+public class SessionDemo extends HttpServlet {
+
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        resp.setCharacterEncoding("utf-8");
+
+        HttpSession session  = req.getSession();
+
+        String id = session.getId();
+
+        /**
+         * Request session 是基于 cookie 实现的
+         * 开启session后, 会自动设置 cookie 的 SESSIONID 值
+         */
+
+        //Tomcat session 最终也是字符串
+        //JWT Spring Template 第三代 认证技术// session 字符串
+
+        /**
+         * Session 生命周期
+         * 默认是 30分钟, 起始计算时间是 从最后一次交互开始计算
+         * 一般用于处理 登陆状态
+         *
+         */
+        session.invalidate(); //销毁Session
+
+
+    }
+}

BIN=BIN
day11/web/WEB-INF/lib/el-api.jar


BIN=BIN
day11/web/WEB-INF/lib/jsp-api.jar


BIN=BIN
day11/web/WEB-INF/lib/servlet-api.jar


+ 12 - 0
day11/web/WEB-INF/web.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
+         version="4.0">
+
+
+    <session-config>
+        <session-timeout>30</session-timeout>
+    </session-config>
+
+</web-app>

+ 16 - 0
day11/web/index.jsp

@@ -0,0 +1,16 @@
+<%--
+  Created by IntelliJ IDEA.
+  User: 武恒
+  Date: 2023/2/7
+  Time: 9:06
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+  <head>
+    <title>$Title$</title>
+  </head>
+  <body>
+  $END$
+  </body>
+</html>

+ 69 - 0
study/src/com/lovecoding/study/domian/Brand.java

@@ -0,0 +1,69 @@
+package com.lovecoding.study.domian;
+
+public class Brand {
+    private int id;
+    private String brandName;
+    private String companyName;
+    private int ordered;
+    private String description;
+    private int status;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getBrandName() {
+        return brandName;
+    }
+
+    public void setBrandName(String brandName) {
+        this.brandName = brandName;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public int getOrdered() {
+        return ordered;
+    }
+
+    public void setOrdered(int ordered) {
+        this.ordered = ordered;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
+    public String toString() {
+        return "Brand{" +
+                "id=" + id +
+                ", brandName='" + brandName + '\'' +
+                ", companyName='" + companyName + '\'' +
+                ", ordered=" + ordered +
+                ", description='" + description + '\'' +
+                ", status=" + status +
+                '}';
+    }
+}

+ 61 - 0
study/src/com/lovecoding/study/domian/User.java

@@ -0,0 +1,61 @@
+package com.lovecoding.study.domian;
+
+public class User {
+
+    private int id;
+    private String username;
+    private String password;
+    private String gender;
+    private String addr;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    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 String getGender() {
+        return gender;
+    }
+
+    public void setGender(String gender) {
+        this.gender = gender;
+    }
+
+    public String getAddr() {
+        return addr;
+    }
+
+    public void setAddr(String addr) {
+        this.addr = addr;
+    }
+
+    @Override
+    public String toString() {
+        return "User{" +
+                "id=" + id +
+                ", username='" + username + '\'' +
+                ", password='" + password + '\'' +
+                ", gender='" + gender + '\'' +
+                ", addr='" + addr + '\'' +
+                '}';
+    }
+}

+ 15 - 0
study/src/com/lovecoding/study/mapper/UserMapper.java

@@ -0,0 +1,15 @@
+package com.lovecoding.study.mapper;
+
+import com.lovecoding.study.domian.User;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+public interface UserMapper {
+    @Select("SELECT * FROM tb_users WHERE username = #{username}")
+    User findUser(String username );
+
+    @Insert("INSERT INTO `tb_users` (`username`, `password`) VALUES (#{username},#{password})")
+    int addUser(@Param("username") String username, @Param("password") String password );
+
+}

+ 29 - 0
study/src/com/lovecoding/study/servlet/TestServlet.java

@@ -0,0 +1,29 @@
+package com.lovecoding.study.servlet;
+
+import com.lovecoding.study.domian.User;
+import com.lovecoding.study.mapper.UserMapper;
+import com.lovecoding.study.utils.MybatisUtils;
+import org.apache.ibatis.session.SqlSession;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@WebServlet("/test")
+public class TestServlet extends HttpServlet {
+
+
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+        SqlSession sqlSession = MybatisUtils.getSession().openSession();
+        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
+        User user = mapper.findUser("zhangsan");
+        System.out.println(  user.getPassword()  );
+
+    }
+
+
+}

+ 83 - 0
study/src/com/lovecoding/study/servlet/UserServlet.java

@@ -0,0 +1,83 @@
+package com.lovecoding.study.servlet;
+
+import com.lovecoding.study.domian.User;
+import com.lovecoding.study.mapper.UserMapper;
+import com.lovecoding.study.utils.MybatisUtils;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+
+@WebServlet("/user")
+public class UserServlet extends HttpServlet{
+
+    //登陆操作
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        String username = req.getParameter("username");
+        String password = req.getParameter("password");
+        SqlSession sqlSession = MybatisUtils.getSession().openSession();
+        if ( username != null && password != null ) {
+            UserMapper mapper = sqlSession.getMapper(UserMapper.class);
+            User user = mapper.findUser(username);
+            if ( user != null ) {
+                if ( user.getPassword().equals(password) ) {
+                    //登陆成功
+                    HttpSession session = req.getSession(true);
+                    session.setAttribute("user", user);
+                    session.removeAttribute("error");
+                    resp.sendRedirect(req.getContextPath() + "/brand.jsp");
+                } else {
+                    //密码不正确
+                    req.getSession(true).setAttribute("error", "密码不正确!");
+                    resp.sendRedirect(req.getContextPath() + "/login.jsp");
+                }
+            } else {
+                //没查到用户信息
+                req.getSession(true).setAttribute("error", "用户名不正确");
+                resp.sendRedirect( req.getContextPath() + "/login.jsp");
+            }
+        } else {
+            //表单没有数据
+            req.getSession(true).setAttribute("error", "请处输入用户名和密码!");
+            resp.sendRedirect(req.getContextPath() + "/login.jsp");
+        }
+
+    }
+
+    //注册操作
+    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        req.setCharacterEncoding("UTF-8");
+        String username = req.getParameter("username");
+        String password = req.getParameter("password");
+
+        if ( username != null && !username.equals("")
+                && password != null && !password.equals("") ) {
+            SqlSession sqlSession = MybatisUtils.getSession().openSession();
+            UserMapper mapper = sqlSession.getMapper(UserMapper.class);
+            User user = mapper.findUser(username);
+            if ( user == null ) {
+                //添加用户
+                mapper.addUser( username, password );
+                sqlSession.commit(true);
+                req.getSession(true).removeAttribute("usernameerror");
+                req.getSession(true).removeAttribute("passworderror");
+                resp.sendRedirect(req.getContextPath()+ "/login.jsp");
+            } else {
+                //用户名已存在
+                req.getSession(true).setAttribute("usernameerror", "用户名已存在");
+                resp.sendRedirect(req.getContextPath()+ "/register.jsp");
+            }
+        } else {
+            //用户没天写表单
+            req.getSession(true).setAttribute("passworderror", "表单项不能为空");
+            resp.sendRedirect(req.getContextPath()+ "/register.jsp");
+        }
+    }
+
+}

+ 33 - 0
study/src/com/lovecoding/study/utils/MybatisUtils.java

@@ -0,0 +1,33 @@
+package com.lovecoding.study.utils;
+
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.apache.ibatis.session.SqlSessionFactoryBuilder;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.net.URL;
+
+public class MybatisUtils {
+
+    static SqlSessionFactory build = null;
+
+    static {
+
+        URL resources = MybatisUtils.class.getClassLoader().getResource("");
+
+        String filePath = resources.getPath() + "../mybatis-config.xml";
+        try {
+            FileInputStream fileInputStream = new FileInputStream(filePath);
+
+            build = new SqlSessionFactoryBuilder().build(fileInputStream);
+
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static SqlSessionFactory getSession(){
+        return build;
+    }
+
+}

BIN=BIN
study/web/WEB-INF/lib/el-api.jar


BIN=BIN
study/web/WEB-INF/lib/jsp-api.jar


BIN=BIN
study/web/WEB-INF/lib/jstl-1.2.jar


BIN=BIN
study/web/WEB-INF/lib/mybatis-3.5.5.jar


BIN=BIN
study/web/WEB-INF/lib/mysql-connector-java-8.0.30.jar


BIN=BIN
study/web/WEB-INF/lib/protobuf-java-3.19.4.jar


BIN=BIN
study/web/WEB-INF/lib/servlet-api.jar


BIN=BIN
study/web/WEB-INF/lib/standard-1.1.2.jar


+ 22 - 0
study/web/WEB-INF/mybatis-config.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+        <!DOCTYPE configuration
+                PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+                "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+<environments default="default">
+    <environment id="default">
+        <transactionManager type="JDBC"></transactionManager>
+        <dataSource type="POOLED">
+            <property name="url" value="jdbc:mysql://127.0.0.1:3406/vip21?useSSL=false"/>
+            <property name="username" value="root"/>
+            <property name="password" value="123456"/>
+            <property name="driver" value="com.mysql.cj.jdbc.Driver"/>
+        </dataSource>
+    </environment>
+</environments>
+
+<mappers>
+    <package name="com.lovecoding.study.mapper" />
+</mappers>
+
+</configuration>

+ 6 - 0
study/web/WEB-INF/web.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
+         version="4.0">
+</web-app>

+ 23 - 0
study/web/addBrand.html

@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>添加品牌</title>
+</head>
+<body>
+<div style="width:400px; margin:0 auto;">
+    <h3>添加品牌</h3>
+    <form action="" method="post">
+        品牌名称:<input name="brandName"><br>
+        企业名称:<input name="companyName"><br>
+        排序:<input name="ordered"><br>
+        描述信息:<textarea rows="5" cols="20" name="description"></textarea><br>
+        状态:
+        <input type="radio" name="status" value="0">禁用
+        <input type="radio" name="status" value="1">启用<br>
+
+        <input type="submit" value="提交">
+    </form>
+</div>
+</body>
+</html>

+ 26 - 0
study/web/brand.jsp

@@ -0,0 +1,26 @@
+<%@ page contentType="text/html; utf-8" pageEncoding="UTF-8" %>
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+<h1> ${sessionScope.user.username} 欢迎您</h1>
+<input type="button" value="新增" ><br>
+<hr>
+<table border="1" cellspacing="0" width="80%">
+    <tr>
+        <th>序号</th>
+        <th>品牌名称</th>
+        <th>企业名称</th>
+        <th>排序</th>
+        <th>品牌介绍</th>
+        <th>状态</th>
+        <th>操作</th>
+    </tr>
+</table>
+
+</body>
+</html>

+ 102 - 0
study/web/css/login.css

@@ -0,0 +1,102 @@
+* {
+    margin: 0;
+    padding: 0;
+}
+
+html {
+    height: 100%;
+    width: 100%;
+    overflow: hidden;
+    margin: 0;
+    padding: 0;
+    background: url(../imgs/Desert1.jpg) no-repeat 0px 0px;
+    background-repeat: no-repeat;
+    background-size: 100% 100%;
+    -moz-background-size: 100% 100%;
+}
+
+body {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    height: 100%;
+}
+
+#loginDiv {
+    width: 37%;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    height: 380px;
+    background-color: rgba(75, 81, 95, 0.3);
+    box-shadow: 7px 7px 17px rgba(52, 56, 66, 0.5);
+    border-radius: 5px;
+}
+
+#name_trip {
+    margin-left: 50px;
+    color: red;
+}
+
+p {
+    margin-top: 30px;
+    margin-left: 20px;
+    color: azure;
+}
+
+
+#remember{
+    margin-left: 15px;
+    border-radius: 5px;
+    border-style: hidden;
+    background-color: rgba(216, 191, 216, 0.5);
+    outline: none;
+    padding-left: 10px;
+    height: 20px;
+    width: 20px;
+}
+#username{
+    width: 200px;
+    margin-left: 15px;
+    border-radius: 5px;
+    border-style: hidden;
+    height: 30px;
+    background-color: rgba(216, 191, 216, 0.5);
+    outline: none;
+    color: #f0edf3;
+    padding-left: 10px;
+}
+#password{
+    width: 202px;
+    margin-left: 15px;
+    border-radius: 5px;
+    border-style: hidden;
+    height: 30px;
+    background-color: rgba(216, 191, 216, 0.5);
+    outline: none;
+    color: #f0edf3;
+    padding-left: 10px;
+}
+.button {
+    border-color: cornsilk;
+    background-color: rgba(100, 149, 237, .7);
+    color: aliceblue;
+    border-style: hidden;
+    border-radius: 5px;
+    width: 100px;
+    height: 31px;
+    font-size: 16px;
+}
+
+#subDiv {
+    text-align: center;
+    margin-top: 30px;
+}
+#loginMsg{
+    text-align: center;
+    color: aliceblue;
+}
+#errorMsg{
+    text-align: center;
+    color:red;
+}

+ 146 - 0
study/web/css/register.css

@@ -0,0 +1,146 @@
+* {
+    margin: 0;
+    padding: 0;
+    list-style-type: none;
+}
+.reg-content{
+    padding: 30px;
+    margin: 3px;
+}
+a, img {
+    border: 0;
+}
+
+body {
+    background-image: url("../imgs/reg_bg_min.jpg") ;
+    text-align: center;
+}
+
+table {
+    border-collapse: collapse;
+    border-spacing: 0;
+}
+
+td, th {
+    padding: 0;
+    height: 90px;
+
+}
+.inputs{
+    vertical-align: top;
+}
+
+.clear {
+    clear: both;
+}
+
+.clear:before, .clear:after {
+    content: "";
+    display: table;
+}
+
+.clear:after {
+    clear: both;
+}
+
+.form-div {
+    background-color: rgba(255, 255, 255, 0.27);
+    border-radius: 10px;
+    border: 1px solid #aaa;
+    width: 424px;
+    margin-top: 150px;
+    margin-left:1050px;
+    padding: 30px 0 20px 0px;
+    font-size: 16px;
+    box-shadow: inset 0px 0px 10px rgba(255, 255, 255, 0.5), 0px 0px 15px rgba(75, 75, 75, 0.3);
+    text-align: left;
+}
+
+.form-div input[type="text"], .form-div input[type="password"], .form-div input[type="email"] {
+    width: 268px;
+    margin: 10px;
+    line-height: 20px;
+    font-size: 16px;
+}
+
+.form-div input[type="checkbox"] {
+    margin: 20px 0 20px 10px;
+}
+
+.form-div input[type="button"], .form-div input[type="submit"] {
+    margin: 10px 20px 0 0;
+}
+
+.form-div table {
+    margin: 0 auto;
+    text-align: right;
+    color: rgba(64, 64, 64, 1.00);
+}
+
+.form-div table img {
+    vertical-align: middle;
+    margin: 0 0 5px 0;
+}
+
+.footer {
+    color: rgba(64, 64, 64, 1.00);
+    font-size: 12px;
+    margin-top: 30px;
+}
+
+.form-div .buttons {
+    float: right;
+}
+
+input[type="text"], input[type="password"], input[type="email"] {
+    border-radius: 8px;
+    box-shadow: inset 0 2px 5px #eee;
+    padding: 10px;
+    border: 1px solid #D4D4D4;
+    color: #333333;
+    margin-top: 5px;
+}
+
+input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus {
+    border: 1px solid #50afeb;
+    outline: none;
+}
+
+input[type="button"], input[type="submit"] {
+    padding: 7px 15px;
+    background-color: #3c6db0;
+    text-align: center;
+    border-radius: 5px;
+    overflow: hidden;
+    min-width: 80px;
+    border: none;
+    color: #FFF;
+    box-shadow: 1px 1px 1px rgba(75, 75, 75, 0.3);
+}
+
+input[type="button"]:hover, input[type="submit"]:hover {
+    background-color: #5a88c8;
+}
+
+input[type="button"]:active, input[type="submit"]:active {
+    background-color: #5a88c8;
+}
+.err_msg{
+    color: red;
+    padding-right: 170px;
+}
+#password_err,#tel_err{
+    padding-right: 195px;
+}
+
+#reg_btn{
+    margin-right:50px; width: 285px; height: 45px; margin-top:20px;
+}
+
+#checkCode{
+    width: 100px;
+}
+
+#changeImg{
+    color: aqua;
+}

BIN=BIN
study/web/imgs/Desert1.jpg


BIN=BIN
study/web/imgs/a.jpg


BIN=BIN
study/web/imgs/reg_bg_min.jpg


+ 30 - 0
study/web/login.jsp

@@ -0,0 +1,30 @@
+<%@ page contentType="text/html; utf-8" pageEncoding="UTF-8" %>
+
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <title>login</title>
+    <link href="css/login.css" rel="stylesheet">
+</head>
+<body>
+<div id="loginDiv" style="height: 350px">
+    <form action="${pageContext.servletContext.contextPath}/user" id="form" method="get">
+        <h1 id="loginMsg">LOGIN IN</h1>
+
+        <div id="errorMsg">${sessionScope.error}</div>
+
+        <p>Username:<input id="username" name="username" type="text"></p>
+        <p>Password:<input id="password" name="password" type="password"></p>
+        <p>Remember:<input id="remember" name="remember" type="checkbox"></p>
+        <div id="subDiv">
+            <input type="submit" class="button" value="login up">
+            <input type="reset" class="button" value="reset">&nbsp;&nbsp;&nbsp;
+            <a href="${pageContext.servletContext.contextPath}/register.jsp">没有账号?</a>
+        </div>
+    </form>
+</div>
+
+</body>
+</html>

+ 50 - 0
study/web/register.jsp

@@ -0,0 +1,50 @@
+<%@ page contentType="text/html; utf-8" pageEncoding="UTF-8" %>
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>欢迎注册</title>
+    <link href="css/register.css" rel="stylesheet">
+</head>
+<body>
+<div class="form-div">
+    <div class="reg-content">
+        <h1>欢迎注册</h1>
+        <span>已有帐号?</span> <a href="${pageContext.servletContext.contextPath}/login.jsp">登录</a>
+    </div>
+    <form id="reg-form" action="${pageContext.servletContext.contextPath}/user" method="post">
+        <table>
+            <tr>
+                <td>用户名</td>
+                <td class="inputs">
+                    <input name="username" type="text" id="username">
+                    <br>
+                    <span id="username_err" class="err_msg" >${sessionScope.usernameerror}</span>
+                </td>
+            </tr>
+            <tr>
+                <td>密码</td>
+                <td class="inputs">
+                    <input name="password" type="password" id="password">
+                    <br>
+                    <span id="password_err" class="err_msg" >${sessionScope.passworderror}</span>
+                </td>
+            </tr>
+            <tr>
+                <td>验证码</td>
+                <td class="inputs">
+                    <input name="checkCode" type="text" id="checkCode">
+                    <img src="imgs/a.jpg">
+                    <a href="#" id="changeImg">看不清?</a>
+                </td>
+            </tr>
+        </table>
+        <div class="buttons">
+            <input value="注 册" type="submit" id="reg_btn">
+        </div>
+        <br class="clear">
+    </form>
+</div>
+</body>
+</html>

+ 23 - 0
study/web/update.html

@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>修改品牌</title>
+</head>
+<body>
+<div style="width:400px; margin:0 auto;">
+    <h3>修改品牌</h3>
+    <form action="" method="post">
+        <input type="hidden" name="id" value="">
+        品牌名称:<input name="brandName" value=""><br>
+        企业名称:<input name="companyName" value=""><br>
+        排&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;序:<input name="ordered" value=""><br>
+        描述信息:<textarea rows="5" cols="20" name="description"></textarea><br>
+        状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态:
+        <input type="radio" name="status" value="0" checked>禁用
+        <input type="radio" name="status" value="1">启用<br>
+        <input type="submit" value="提交">
+    </form>
+</div>
+</body>
+</html>