宁波实习记录(五)——基于SSM用户登录

今天学习了最简单的登录功能,老师提供了jsp页面,我们主要完成了java代码的编写

基础知识提要
监听器
监听器就是监听某个域对象的的状态变化的组件
监听器的相关概念:
事件源:被监听的对象(三个域对象 request、session、servletContext)
监听器:监听事件源对象事件源对象的状态的变化都会触发监听器
注册监听器:将监听器与事件源进行绑定
第一维度按照被监听的对象划分:ServletRequest域、HttpSession域、ServletContext域
第二维度按照监听的内容分:监听域对象的创建与销毁的、监听域对象的属性变化的
过滤器
filter是对客户端访问资源的过滤,符合条件放行,不符合条件不放行,并且可以对目标资源访问前后进行逻辑处理。作用:代码的抽取(可以对request设置编码,这样所有走过的servlet的编码都是统一的,没必要每一个都写)权限管理(在filter内部去除当前登录客户的角色,再看看访问的资源,如果匹配则放行,不匹配则不放行)

一、新建项目

和上次一样,新建一个maven项目
在这里插入图片描述
在这里插入图片描述在这里插入图片描述
需要我们写的只有UserInfo;UserInfoController;IUserInfoDao;IUserInfoService和UserInfoService。然后就是UserMapper.xml

二、实现细节

UserInfo

package com.zhongruan.bean;

public class UserInfo {
    private int id;
    private String name;
    private String password;

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getPassword() {
        return password;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "user{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}

IUserInfoDao

package com.zhongruan.dao;

import com.zhongruan.bean.UserInfo;

import java.util.List;

public interface IUserInfoDao {
    public List<UserInfo> findAll();
    public UserInfo login(UserInfo userInfo);//登录方法
}

UserMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.zhongruan.dao.IUserInfoDao" >
    <select id="findAll" resultType="com.zhongruan.bean.UserInfo">
        select * from userinfo
    </select>
    <select id="login" parameterType="com.zhongruan.bean.UserInfo" resultType="com.zhongruan.bean.UserInfo">
        select * from userinfo where name=#{name} and password=#{password}
    </select>
</mapper>

IUserInfoService

package com.zhongruan.service;

import com.zhongruan.bean.UserInfo;

import java.util.List;

public interface IUserInfoService {
    public List<UserInfo> findAll();
    public boolean login(UserInfo userInfo);
}

UserInfoServiceImpl

package com.zhongruan.service.impl;

import com.zhongruan.bean.UserInfo;
import com.zhongruan.dao.IUserInfoDao;
import com.zhongruan.service.IUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userInfoService")
public class UserInfoServiceImpl implements IUserInfoService {
    @Autowired
    IUserInfoDao userInfoDao;
    @Override
    public List<UserInfo> findAll() {
        return userInfoDao.findAll();
    }

    @Override
    public boolean login(UserInfo userInfo) {
        UserInfo user=userInfoDao.login(userInfo);
        if(user!=null){
            return true;
        }else{
            return false;
        }


    }
}

UserInfoController控制页面跳转

package com.zhongruan.controller;

import com.zhongruan.bean.UserInfo;
import com.zhongruan.dao.IUserInfoDao;
import com.zhongruan.service.IUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("user")
public class UserInfoController {
    @Autowired
    IUserInfoService userInfoService;

    @RequestMapping("/findAll.do")
    public ModelAndView findAll(){
        List<UserInfo> userInfos = userInfoService.findAll();
        ModelAndView mv =new ModelAndView();
        mv.addObject("userInfos",userInfos);
        mv.setViewName("user-list");
        return mv;
    }

    @RequestMapping("/login.do")
    public ModelAndView login(UserInfo userInfo){
        boolean flag=userInfoService.login(userInfo);
        ModelAndView mv =new ModelAndView();
        if (flag){
            mv.setViewName("main");
        }else {
            mv.setViewName("../failer");
        }
        return mv;


    }
}

main.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
   pageEncoding="UTF-8" isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- 页面meta -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>ITCAST - AdminLTE2定制版</title>
<meta name="description" content="AdminLTE2定制版">
<meta name="keywords" content="AdminLTE2定制版">

<meta
   content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
   name="viewport">

  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>

<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/ionicons/css/ionicons.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/iCheck/square/blue.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/morris/morris.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/datepicker/datepicker3.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.theme.default.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/select2/select2.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/adminLTE/css/AdminLTE.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/adminLTE/css/skins/_all-skins.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/css/style.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.skinNice.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/bootstrap-slider/slider.css">
</head>

<body class="hold-transition skin-blue sidebar-mini">

   <div class="wrapper">

      <!-- 页面头部 -->
      <jsp:include page="header.jsp"></jsp:include>
         <!-- 页面头部 /-->

      <!-- 导航侧栏 -->
      <jsp:include page="aside.jsp"></jsp:include>
      <!-- 导航侧栏 /-->

      <!-- 内容区域 -->
      <div class="content-wrapper">

         <img src="${pageContext.request.contextPath}/img/center.jpg"
            width="100%" height="100%" />

      </div>
      <!-- 内容区域 /-->

      <!-- 底部导航 -->
      <footer class="main-footer">
      <div class="pull-right hidden-xs">
         <b>Version</b> 1.0.8
      </div>
      <strong>Copyright &copy; 2014-2017 <a
         href="http://www.chinasofti.com">研究院研发部</a>.
      </strong> All rights reserved. </footer>
      <!-- 底部导航 /-->

   </div>

   <script
      src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/jQueryUI/jquery-ui.min.js"></script>
   <script>
      $.widget.bridge('uibutton', $.ui.button);
   </script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/raphael/raphael-min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/morris/morris.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/sparkline/jquery.sparkline.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/knob/jquery.knob.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/daterangepicker/moment.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.zh-CN.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/datepicker/bootstrap-datepicker.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/slimScroll/jquery.slimscroll.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/fastclick/fastclick.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/iCheck/icheck.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/adminLTE/js/app.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/select2/select2.full.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.zh-CN.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/bootstrap-markdown.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/locale/bootstrap-markdown.zh.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/markdown.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/to-markdown.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/ckeditor/ckeditor.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.extensions.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/datatables/jquery.dataTables.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/chartjs/Chart.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.resize.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.pie.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.categories.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-slider/bootstrap-slider.js"></script>
   <script>
      $(document).ready(function() {
         // 选择框
         $(".select2").select2();

         // WYSIHTML5编辑器
         $(".textarea").wysihtml5({
            locale : 'zh-CN'
         });
      });

      // 设置激活菜单
      function setSidebarActive(tagUri) {
         var liObj = $("#" + tagUri);
         if (liObj.length > 0) {
            liObj.parent().parent().addClass("active");
            liObj.addClass("active");
         }
      }

      $(document).ready(function() {
         // 激活导航位置
         setSidebarActive("admin-index");
      });
   </script>
</body>

</html>

failer.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
   pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

<head>
<!-- 页面meta -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>数据 - AdminLTE2定制版</title>
<meta name="description" content="AdminLTE2定制版">
<meta name="keywords" content="AdminLTE2定制版">

<!-- Tell the browser to be responsive to screen width -->
<meta
   content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
   name="viewport">








<!-- jQuery 2.2.3 -->
<!-- jQuery UI 1.11.4 -->
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<!-- Bootstrap 3.3.6 -->
<!-- Morris.js charts -->
<!-- Sparkline -->
<!-- jvectormap -->
<!-- jQuery Knob Chart -->
<!-- daterangepicker -->
<!-- datepicker -->
<!-- Bootstrap WYSIHTML5 -->
<!-- Slimscroll -->
<!-- FastClick -->
<!-- iCheck -->
<!-- AdminLTE App -->
<!-- 表格树 -->
<!-- select2 -->
<!-- bootstrap color picker -->
<!-- bootstrap time picker -->
<!--<script src="${pageContext.request.contextPath}/${pageContext.request.contextPath}/${pageContext.request.contextPath}/plugins/timepicker/bootstrap-timepicker.min.js"></script>-->
<!-- Bootstrap WYSIHTML5 -->
<!--bootstrap-markdown-->
<!-- CK Editor -->
<!-- InputMask -->
<!-- DataTables -->
<!-- ChartJS 1.0.1 -->
<!-- FLOT CHARTS -->
<!-- FLOT RESIZE PLUGIN - allows the chart to redraw when the window is resized -->
<!-- FLOT PIE PLUGIN - also used to draw donut charts -->
<!-- FLOT CATEGORIES PLUGIN - Used to draw bar charts -->
<!-- jQuery Knob -->
<!-- Sparkline -->
<!-- Morris.js charts -->
<!-- Ion Slider -->
<!-- Bootstrap slider -->
<!-- 页面meta /-->

<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/ionicons/css/ionicons.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/iCheck/square/blue.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/morris/morris.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/datepicker/datepicker3.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.theme.default.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/select2/select2.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/adminLTE/css/AdminLTE.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/adminLTE/css/skins/_all-skins.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/css/style.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.skinNice.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/bootstrap-slider/slider.css">
</head>

<body class="hold-transition skin-purple sidebar-mini">

   <div class="wrapper">

      <!-- 页面头部 -->
      <!-- 页面头部 -->
<header class="main-header">
   <!-- Logo -->
   <a href="all-admin-index.html" class="logo"> <!-- mini logo for sidebar mini 50x50 pixels -->
      <span class="logo-mini"><b>数据</b></span> <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><b>数据</b>后台管理</span>
   </a>
   <!-- Header Navbar: style can be found in header.less -->
   <nav class="navbar navbar-static-top">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="offcanvas"
         role="button"> <span class="sr-only">Toggle navigation</span>
      </a>

      <div class="navbar-custom-menu">
         <ul class="nav navbar-nav">

            <li class="dropdown user user-menu"><a href="#"
               class="dropdown-toggle" data-toggle="dropdown"> <img
                  src="${pageContext.request.contextPath}/img/user2-160x160.jpg"
                  class="user-image" alt="User Image"> <span class="hidden-xs">
                     未登录
               </span>

            </a>
               <ul class="dropdown-menu">
                  <!-- User image -->
                  <li class="user-header"><img
                     src="${pageContext.request.contextPath}/img/user2-160x160.jpg"
                     class="img-circle" alt="User Image"></li>

                  <!-- Menu Footer-->
                  <li class="user-footer">
                     <div class="pull-left">
                        <a href="#" class="btn btn-default btn-flat">修改密码</a>
                     </div>
                     <div class="pull-right">
                        <a href="${pageContext.request.contextPath}/logout.do"
                           class="btn btn-default btn-flat">注销</a>
                     </div>
                  </li>
               </ul></li>

         </ul>
      </div>
   </nav>
</header>
<!-- 页面头部 /-->
      <!-- 页面头部 /-->

      <!-- 导航侧栏 -->
      <aside class="main-sidebar">
   <!-- sidebar: style can be found in sidebar.less -->
   <section class="sidebar">
      <!-- Sidebar user panel -->
      <div class="user-panel">
         <div class="pull-left image">
            <img src="${pageContext.request.contextPath}/img/user2-160x160.jpg"
               class="img-circle" alt="User Image">
         </div>
         <div class="pull-left info">
            <p>
               未登录
            </p>
            <a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
         </div>
      </div>

      <!-- sidebar menu: : style can be found in sidebar.less -->
      <ul class="sidebar-menu">
         <li class="header">菜单</li>
         <li id="admin-index"><a
            href="${pageContext.request.contextPath}/pages/main.jsp"><i
               class="fa fa-dashboard"></i> <span>首页</span></a></li>

         <li class="treeview"><a href="#"> <i class="fa fa-cogs"></i>
               <span>系统管理</span> <span class="pull-right-container"> <i
                  class="fa fa-angle-left pull-right"></i>
            </span>
         </a>
            <ul class="treeview-menu">

               <li id="system-setting"><a
                  href="#"> <i
                     class="fa fa-circle-o"></i> 用户管理
               </a></li>
               <li id="system-setting"><a href="#">
                     <i class="fa fa-circle-o"></i> 角色管理
               </a></li>

            </ul></li>
         <li class="treeview"><a href="#"> <i class="fa fa-cube"></i>
               <span>基础数据</span> <span class="pull-right-container"> <i
                  class="fa fa-angle-left pull-right"></i>
            </span>
         </a>
            <ul class="treeview-menu">

               <li id="system-setting"><a
                  href="#">
                     <i class="fa fa-circle-o"></i> 产品管理
               </a></li>

            </ul></li>

      </ul>
   </section>
   <!-- /.sidebar -->
</aside>
      <!-- 导航侧栏 /-->

      <!-- 内容区域 -->
      <div class="content-wrapper">
         <!-- Content Header (Page header) -->
         <section class="content-header">
            <h1>登录失败 页面</h1>

            <ol class="breadcrumb">
               <li><a href="${pageContext.request.contextPath}/index.jsp"><i
                     class="fa fa-dashboard"></i> 首页</a></li>
               <li class="active">登录失败</li>
            </ol>

         </section>

         <!-- Main content -->
         <section class="content">
            <div class="error-page">
            

               <div class="error-content">
                  
                  <p>
                     登录失败 , 你可以 <a href="${pageContext.request.contextPath}/login.jsp">返回到登录页面</a>
                     重新登录
                  </p>

                  
               </div>
               <!-- /.error-content -->
            </div>
            <!-- /.error-page -->
         </section>
         <!-- /.content -->
      </div>
      <!-- 内容区域 /-->

      <!-- 底部导航 -->
      <footer class="main-footer">
         <div class="pull-right hidden-xs">
            <b>Version</b> 1.0.8
         </div>
         <strong>Copyright &copy; 2014-2017 <a
            href="http://www.lhl.cn">研究院研发部</a>.
         </strong> All rights reserved.
      </footer>
      <!-- 底部导航 /-->

   </div>


   <script
      src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/jQueryUI/jquery-ui.min.js"></script>
   <script>
      $.widget.bridge('uibutton', $.ui.button);
   </script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/raphael/raphael-min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/morris/morris.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/sparkline/jquery.sparkline.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/knob/jquery.knob.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/daterangepicker/moment.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.zh-CN.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/datepicker/bootstrap-datepicker.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/slimScroll/jquery.slimscroll.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/fastclick/fastclick.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/iCheck/icheck.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/adminLTE/js/app.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/select2/select2.full.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.zh-CN.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/bootstrap-markdown.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/locale/bootstrap-markdown.zh.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/markdown.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/to-markdown.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/ckeditor/ckeditor.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.extensions.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/datatables/jquery.dataTables.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/chartjs/Chart.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.resize.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.pie.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.categories.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap-slider/bootstrap-slider.js"></script>
   <script>
      $(document).ready(function() {
         // 选择框
         $(".select2").select2();

         // WYSIHTML5编辑器
         $(".textarea").wysihtml5({
            locale : 'zh-CN'
         });
      });

      // 设置激活菜单
      function setSidebarActive(tagUri) {
         var liObj = $("#" + tagUri);
         if (liObj.length > 0) {
            liObj.parent().parent().addClass("active");
            liObj.addClass("active");
         }
      }

      $(document).ready(function() {
         setSidebarActive("admin-500");
      });
   </script>
</body>

</html>

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<html>
<body>
<jsp:forward page="/login.jsp"></jsp:forward>
</body>
</html>

login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
   pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>中软ETC用户管理系统</title>

<meta
   content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
   name="viewport">

<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/ionicons/css/ionicons.min.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/adminLTE/css/AdminLTE.css">
<link rel="stylesheet"
   href="${pageContext.request.contextPath}/plugins/iCheck/square/blue.css">
</head>

<body class="hold-transition login-page">
   <div class="login-box">
      <div class="login-logo">
         <a href="all-admin-index.html">中软<b>ETC</b>用户管理系统</a>
      </div>
      <!-- /.login-logo -->
      <div class="login-box-body">
         <p class="login-box-msg">登录系统</p>

         <form action="${pageContext.request.contextPath}/user/login.do" method="post">
            <div class="form-group has-feedback">
               <input type="text" name="name" class="form-control"
                  placeholder="用户名"> <span
                  class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
               <input type="password" name="password" class="form-control"
                  placeholder="密码"> <span
                  class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="row">
               <div class="col-xs-8">
                  <div class="checkbox icheck">
                     <label><input type="checkbox"> 记住 下次自动登录</label>
                  </div>
               </div>
               <!-- /.col -->
               <div class="col-xs-4">
                  <button type="submit" class="btn btn-primary btn-block btn-flat">登录</button>
               </div>
               <!-- /.col -->
            </div>
         </form>

         <a href="#">忘记密码</a><br>


      </div>
      <!-- /.login-box-body -->
   </div>
   <!-- /.login-box -->

   <!-- jQuery 2.2.3 -->
   <!-- Bootstrap 3.3.6 -->
   <!-- iCheck -->
   <script
      src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
   <script
      src="${pageContext.request.contextPath}/plugins/iCheck/icheck.min.js"></script>
   <script>
      $(function() {
         $('input').iCheck({
            checkboxClass : 'icheckbox_square-blue',
            radioClass : 'iradio_square-blue',
            increaseArea : '20%' // optional
         });
      });
   </script>
</body>

</html>

三、运行结果

在这里插入图片描述

在这里插入图片描述
完整代码包见

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值