系统一共分为1个角色分别是:用户
登录
- html>
- <html lang="en">
-
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>图书管理系统登录title>
-
- <link rel="shortcut icon" href="favicon.ico" />
- <link rel="stylesheet" href="static/bootstrap-3.4.1/css/bootstrap.min.css">
- <link rel="stylesheet" href="static/bootstrap-3.4.1/css/bootoast.css">
- head>
- <style>
- /* 初始化代码 */
- * {
- margin: 0;
- padding: 0;
- }
-
- html,
- body {
- width: auto;
- height: 100%;
- }
-
- /* 初始化代码结束 */
-
-
- .container {
- width: 100%;
- height: 100%;
- background:url("static/img/preview.gif") no-repeat;
- background-size: 100% 100%;
- }
-
- .w {
-
- margin: 14% auto;
- width: 800px;
- }
-
- /* 这是左边的框框内容!!!!!!! ! */
- .container .login-left .login-logo img {
- display: block;
- width: 80%;
- height: 80%;
- margin: 40px auto;
- }
-
- .login-left {
- width: 400px;
- height: 400px;
- float: left;
- background-color: #ffffff55;
- border-radius: 4px;
- box-shadow: 0 0 2px #fff;
- }
-
- /* 这是右边的框框内容!!!!!!!!! */
-
- .login-right {
- width: 400px;
- height: 400px;
- float: left;
- background-color: #fff;
- opacity: 0.9;
- border-radius: 4px;
- box-shadow: 0 0 2px #fff;
- }
-
- .login-right .biaoti {
- margin-top: 40px;
- text-align: center;
- }
-
- .form {
- margin-top: 10px;
- padding: 40px 40px 10px 10px;
- }
-
- .form i {
- font-size: 18px;
- color: #333;
- }
-
- .form a {
- display: block;
- float: right;
- text-decoration: none;
- color: #333;
- }
-
- .form .login-btn {
- width: 90%;
- margin-top: 10px;
- background-color: rgb(100,204,195);
- }
-
- .footer {
- position: absolute;
- bottom: 30px;
- left: 0;
- right: 0;
- text-align: center;
- font-size: 14px;
- color: rgb(0, 0, 0);
- }
- /*验证码*/
- .vcode-box{
- position: relative;
- }
- .vcode-box img{
- position: absolute;
- top: 1px;
- right: 5%;
- cursor: pointer;
- }
- style>
- <script src="./static/bootstrap-3.4.1/js/jquery-3.6.0.min.js">script>
- <script src="./static/bootstrap-3.4.1/js/bootstrap.js">script>
- <script src="./static/bootstrap-3.4.1/js/bootoast.js">script>
- <script>
- function login(){
- var username = $("#username").val();
- var password = $("#password").val();
- $.post("./LoginController",{"username" : username,"password" : password},function(data){
- if(data === "success") {
-
- location.href = "./home.html";
- }else{
- alert("用户名或密码错误!!!");
- }
- })
- }
- script>
- <body>
- <div class="container">
- <div class="w">
- <div class="login-left">
- <div class=login-logo>
-
- div>
- div>
- <div class="login-right">
- <h1 class="biaoti">登录h1>
- <form class="form-horizontal form" id="myForm" action="/pm/users/login">
- <div class="form-group">
- <label class="col-md-2 control-label"><i class="glyphicon glyphicon-home">i>label>
- <div class="col-md-10">
- <input type="text" class="form-control" id="username" name="username" placeholder="用户">
- div>
- div>
- <div class="form-group">
- <label class="col-md-2 control-label"><i class="glyphicon glyphicon-lock">i>label>
- <div class="col-md-10">
- <input type="password" class="form-control" id="password" name="password" placeholder="密码">
- div>
- div>
-
- <div class="form-group">
- <div class="col-md-offset-2 col-md-10">
- <div class="checkbox">
- <label> <input type="checkbox"> 记住密码
- label>
- <a href="">忘记密码a>
- div>
-
- div>
- div>
- <div class="form-group">
- <div class="col-md-offset-2 col-md-10">
- <button type="button" class="btn btn-default login-btn" id="login-btn" onclick="login()">登录button>
- div>
- div>
- form>
- div>
- <div class="footer">
- <p>技术支持p>
- div>
- div>
- div>
- body>
-
- html>
- package com.yq.bookmgr.controller;
-
- import java.io.IOException;
- 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 com.yq.bookmgr.entity.UserEntity;
- import com.yq.bookmgr.service.UserService;
- import com.yq.bookmgr.service.impl.UserServiceImpl;
-
-
- @WebServlet("/LoginController")
- public class LoginController extends HttpServlet {
- private static final long serialVersionUID = 1L;
- private UserService userService = new UserServiceImpl();
-
- public LoginController() {
- super();
- }
-
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String username = request.getParameter("username");
- String password = request.getParameter("password");
-
- UserEntity user = new UserEntity(username,password);
-
- if(userService.login(user)) {
- response.getWriter().append("success");
- }else {
- response.getWriter().append("failed");
- }
- response.getWriter().flush();
-
-
- }
-
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- doGet(request, response);
- }
-
- }