权限管理系统 shiro + ssm实现

权限管理系统


配置文件
#tomcat访问端口
server.port=8180
logging.level.tk.mybatis=TRACE

#数据源配置信息
datasource.initialSize=5
datasource.minIdle=5
datasource.maxActive=20
datasource.testOnBorrow=true
datasource.filters=stat,wall
#数据源名称(与下列配置的数据源对应,多个数据源要配多个名称)
jdbc.datasources=ds,ds1
#主数据源,默认的
jdbc.ds.dsType=com.alibaba.druid.pool.DruidDataSource
jdbc.ds.driverClassName=com.mysql.jdbc.Driver
jdbc.ds.url=jdbc:mysql://localhost:3306/demo-boot
jdbc.ds.username=root
jdbc.ds.password=root

#从数据源1
jdbc.ds1.dsType=com.alibaba.druid.pool.DruidDataSource
jdbc.ds1.driverClassName=com.mysql.jdbc.Driver
jdbc.ds1.url=jdbc:mysql://localhost:3306/demo-boot1
jdbc.ds1.username=root
jdbc.ds1.password=root

##redis配置
#redis.host=127.0.0.1
#redis.port=6379
#redis.password=
##最大连接数
#redis.maxTotal=600
##最大空闲连接
#redis.maxIdle=300
##最小空闲连接
#redis.minIdle=1
##等待可用连接的最大时间
#redis.maxWaitMillis=100000
##当调用borrow Object方法时,是否进行有效性检查
#redis.testOnBorrow=true
##缓存有效时长
#redis.defaultExpiration=0

#缓存名称
spring.cache.cache-names=CACHE_KEY

#druid监控信息访问
#IP白名单
druid.allow=127.0.0.1
#IP黑名单
druid.deny=192.168.0.200
#登录名
druid.loginUsername=admin
#登录密码
druid.loginPassword=admin
#是否重置数据
druid.resetEnable=false

#虚拟访问路径
global.upload.path=/upload/
#真实存放路径
global.upload.docBase=/service/upload/

#单个文件上传限制
spring.http.multipart.maxFileSize=10Mb
#单次文件上传限制
spring.http.multipart.maxRequestSize=100Mb

#springmvc视图
spring.mvc.view.prefix=/WEB-INF/pages/
spring.mvc.view.suffix=.jsp

mybatis.type-aliases-package=com.xe.*.model
mybatis.mapper-locations=classpath:mapper/*.xml
mapper.mappers=com.xe.demo.common.dao.MyMapper
mapper.not-empty=false
mapper.identity=MYSQL

pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count\=countSql


用户管理


页面采用jsp页面编写

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>权限系统-登陆</title>

		<meta name="description" content="User login page" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
		<script type="text/javascript">
			window.jQuery || document.write("<script src='${ctx}/assets/js/jquery.js'>"+"<"+"/script>");
		</script>
		<script src="${ctx}/assets/js/jquery.cookie.js"></script>
		<script src="${ctx}/assets/js/util/md5.js"></script>
		<style>
       *{box-sizing:border-box;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;margin:0;padding:0}
        a,button,input,select,textarea{outline:0}
        *,a{-webkit-tap-highlight-color:transparent}
        a{color:#333;text-decoration:none}
        img{margin:0;padding:0;border:none;vertical-align:middle}
        html{font-family:"Helvetica Neue",Helvetica,STHeiTi,Arial,sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}
        /*body{color:#333;font-size:14px;width:100%;height:100%;}*/

        body{
            background-color: #3d4e66;
        }

        /* 清除浮动 */
        .z-clearfix:after,
        .z-clearfix:before {
          content: ".";
          visibility: hidden;
          display: block;
          font-size: 0;
          clear: both;
          height: 0; }
        .z-login-wrap{
            position: relative;
            width:640px;
            margin:0 auto;
            font-family: "微软雅黑";
        }
        .z-login-box{
            width: 489px;
            height: 562px;
            margin:130px  auto 0 auto;
            background: url(${ctx}/assets/images/login/log01.png) no-repeat;
        }
        .z-login-box .z-content{
            
        }
        .z-content .z-title{
            margin:95px auto 0 auto;
            text-align: center;
        }
        .z-content .z-title h1{
            font-size: 28px;
            color: #fff;
            font-weight: normal !important;
        }
        .z-content strong{
            color: #EF8F05;
            font-weight: normal !important;
        }
        .z-content .z-title p{
            margin-top: 5px;
            color: #fff;
        }
        .z-content .z-form{
            text-align: center;
            width: 337px;
            margin: 0 auto;
            padding-top: 30px;
        }

        .form-item{
            display: block;
            overflow: hidden;
            height: auto;
            background: #f5f5f5;
            border-radius:3px;
            margin-bottom: 18px;
        }
        .form-item >input{
            width: 100%;
            padding:12px;
            border:0;
            color: #88A4C8;
            font-size: 16px;
        }
        input::-webkit-input-placeholder{
            font-family: "微软雅黑";
            color: #88A4C8;
        }
        input::-moz-placeholder{
            font-family: "微软雅黑";
        }

        .z-code-box{
            background-color:#495E7A !important; 
        }
        .z-code-box >input{
            width: 240px;
            float: left;
            border-radius: 3px;
        }
        .z-code-box .z-code{
           float: right;
           width: 80px;
           height: 42px;
           border-radius: 3px;
           overflow: hidden;
           
        }

        .z-form .z-inline{
            display: block;
            margin-top: 15px;
            font-size: 14px;
            color: #fff;
        }
        .z-form .z-inline span{
            display: inline-block;
            margin-left: 5px;
            vertical-align: middle;
        }


        .z-login-btn{
            width: 100%;
            padding:12px;
            background-color: #19b394;
            border-radius: 3px;
            border:0; 
            font-family: "微软雅黑";
            font-size: 16px;
            color: #fff;
        }

        .z-login-btn:hover,
        .z-login-btn:active,
        .z-login-btn:focus:active,
        .z-login-btn:focus:hover,
        .z-code:hover,
        .z-switch:hover{
            cursor: pointer;
        }

        .z-err{
			font-size: 14px;
			color: #EF6C6B;
			margin: 5px auto;
			
        }

        .z-shadow{
            position: absolute;
            top: 145px;
            left: 0;
            z-index: -1;
            width: 866px;
            height: 686px;
            background-repeat: no-repeat;
            background: url(${ctx}/assets/images/login/log02.png) no-repeat;
            background-position: 75px 0px;
        }

        /*开关*/
        .z-switch {
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none;
            position: relative;
            width: 50px;
            height: 26px;
            border: 1px solid #dfdfdf;
            outline: 0;
            border-radius: 16px;
            box-sizing: border-box;
            background: #dfdfdf;
            vertical-align: middle;
        }

        .z-switch:after {
            width: 24px;
            background-color: #fff;
            box-shadow: 0 1px 3px rgba(0,0,0,.4);
        }
        .z-switch:after, .z-switch:before {
            content: " ";
            position: absolute;
            top: 0;
            left: 0;
            height: 24px;
            border-radius:12px;
            -webkit-transition: -webkit-transform .3s;
            -moz-transition: -webkit-transform .3s;
            transition: -webkit-transform .3s;
            transition: transform .3s;
            transition: transform .3s,
            -webkit-transform .3s;
            -moz-transform .3s;
        }

        .z-switch:checked {
            border-color: #19b394;
            background-color: #19b394;
        }
        .z-switch:checked:after {
            -webkit-transform: translateX(24px);
            -moz-transform: translateX(24px);
            transform: translateX(24px);
        }

        .z-switch:checked:before {
            -webkit-transform: scale(0);
            -moz-transform: scale(0);
            transform: scale(0);
        }


        .z-loading-wrap{
            overflow: hidden;
            position: fixed;
            top: 0;
            left: 0;
            z-index: 1000;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,.5);
            display:none;
        }

        .z-msg{
          width: 100%;
          height: 100px;
          position: relative;
          text-align: center;
          top: 360px;
          font-size: 14px;
          color: #fff;
          font-family: "微软雅黑";
        }

        .spinner {
          width: 100px;
          height: 100px;
          position: relative;
          top: 350px;
          margin:0 auto;
        }
         
         .double-bounce2 {
            background-color: #19b394 !important;
         }
        .double-bounce1, .double-bounce2 {
          width: 100%;
          height: 100%;
          border-radius: 50%;
          background-color: #67CF22;
          opacity: 0.6;
          position: absolute;
          top: 0;
          left: 0;
           
          -webkit-animation: bounce 2.0s infinite ease-in-out;
          animation: bounce 2.0s infinite ease-in-out;
        }
         
        .double-bounce2 {
          -webkit-animation-delay: -1.0s;
          animation-delay: -1.0s;
        }
         
        @-webkit-keyframes bounce {
          0%, 100% { -webkit-transform: scale(0.0) }
          50% { -webkit-transform: scale(1.0) }
        }
         
        @keyframes bounce {
          0%, 100% {
            transform: scale(0.0);
            -webkit-transform: scale(0.0);
          } 50% {
            transform: scale(1.0);
            -webkit-transform: scale(1.0);
          }
        }
        .z-switch:checked + #remenber{
            border-color: #19b394;
            background-color: #19b394;
        }
        .z-switch:checked + #remenber:after{
             -webkit-transform: translateX(24px);
             -moz-transform: translateX(24px);
             transform: translateX(24px);
         } 
         .z-switch:checked + #remenber:before{
            -webkit-transform: scale(0);
            transform: scale(0)
         }
    </style>
	</head>

	<body>
    <div class="z-login-wrap">
        <div class="z-login-box">
            <div class="z-content z-clearfix">
                <div class="z-title">
                    <h1>
                        <img src="${ctx}/assets/images/login/log03.png">
                        <span>权限管理系统</span>
                    </h1>
                    <p>©CZH</p>
                </div>

                <div class="z-form">
                    <form id="loginForm">
                        <label class="form-item z-clearfix">
                            <input type="text" name="username" id="username" class="form-control" placeholder="请输入用户">
                            <i class="ace-icon fa fa-user"></i>
                        </label>
                        <label class="form-item z-clearfix">
                            <input  type="password" id="password" class="form-control" placeholder="请输入密码" />
                            <i class="ace-icon fa fa-user"></i>
                        </label>

                        <label class="form-item z-clearfix z-code-box" style="margin-bottom: 0px;" id="showVcode"></label>
                        
                        <p id="err" class="z-err">${err}</p>

                        <button type="button" class="z-login-btn" οnclick="javascript:login();" >登录</button>

                        <label class="inline z-inline">
                            <input type="checkbox" id="setcheck" name="remenber" class="z-switch" style="position: absolute;opacity: 0;" checked="checked">
                            <span class="z-switch" id="remenber"></span>
                            <span>记住登录</span>
                        </label>
                    </form>
                </div>
            </div>
        </div>
        <div class="z-shadow"></div>
    </div>

    <div class="z-loading-wrap">
        <div class="spinner">
          <div class="double-bounce1"></div>
          <div class="double-bounce2"></div>
        </div>
        <div class="z-msg">拼命加速,正在登录中...</div>
    </div>
    <script type="text/javascript">
		//点击图片刷新验证码
		function vcodeclick() {
			$("#vcode").select();
			$("#vimg").attr("src", "${ctx}/getVcode?random=" + Math.random());
		}
		//获取cookie值设置到文本框
		function setValue(){
			var namevalue = $("#username").val();
			if("" != namevalue){
				var cookieName = namevalue + "userinfo";
				var userinfo = $.cookie(cookieName);
				if(undefined != userinfo && "" != userinfo){
					var infos = userinfo.split("&");
					for(var i in infos){
						if(0 == i){
							$("#username").val(infos[i]);
						}else if(1 == i){
							$("#password").val(infos[i]);
						}
					}
				}
			}else{
				var username = $.cookie("username");
				if(undefined != username && "" != username){
					$("#username").val(username);
				}
				var password = $.cookie("password");
				if(undefined != password && "" != password){
					$("#password").val(password);
				}
			}
		}
		setValue();
		
		$("#username").blur(function(){
			setValue();
		});
		function login(){
			$("#errDiv").hide();
			$("#err").html("");
			var username = $("#username").val();
			if("" == username){
				$("#errDiv").show();
				$("#err").html("用户名不能为空");
				$("#username").focus();
				return;
			}
			var password = $("#password").val();
			if("" == password){
				$("#errDiv").show();
				$("#err").html("密码不能为空");
				$("#password").focus();
				return;
			}
			if(password.length <= 20){
				password = hex_md5(password);
			}
			var data = "username=" + username + "&password=" + password;
			var vcode = $("#vcode").val();
			if(undefined != vcode){
				if("" == vcode){
					$("#errDiv").show();
					$("#err").html("验证码不能为空");
					$("#vcode").focus();
					return;
				}
				data += "&vcode=" + vcode;
			}
			$(".z-loading-wrap").show();
			$.ajax({
				url: "${ctx}/admin/login",
				data: data,
				type: "post",
				dataType: "json",
				beforeSend: function(xhr){
					xhr.setRequestHeader("vcode","1");
				},
				success: function(req){
					if(req.retcode == 1){
						var remenber = $("#setcheck").is(":checked");
						var cookieName = username + ":userinfo";
						if(remenber){
							var cookieValue = username + "&" + password;
							//设置cookie值有效期30天
							$.cookie(cookieName, cookieValue, {expires:30});
							$.cookie("username", username, {expires:30});
							$.cookie("password", password, {expires:30});
						}else{
							$.cookie(cookieName, "");
							$.cookie("username", "");
							$.cookie("password", "");
						}
						window.location.href = "${ctx}/admin/main"
					} else {
						$(".z-loading-wrap").hide();
						$("#vcode").select();
						$("#vimg").attr("src", "${ctx}/getVcode?random=" + Math.random());
						var msg = req.retmsg;
						var end = msg.lastIndexOf("|");
						if(end > 0){
							var errTimes = msg.substring(end + 1, msg.length);
							if(3 <= errTimes && undefined == vcode){
								var html = [];
						        html.push('<input type="text" name="vcode" id="vcode" maxlength="4" class="form-control" placeholder="验证码">');
						        html.push('<img class="z-code" id="vimg" src="${ctx}/getVcode" οnclick="vcodeclick()" title="验证码" alt="验证码">');
						        $("#showVcode").append(html.join(''));
							}
							msg = msg.substring(0, end);
						}
						$("#err").html(msg);
					}
				},
				error: function(req){
					$(".z-loading-wrap").hide();
					$("#vcode").select();
					$("#vimg").attr("src", "${ctx}/getVcode?random=" + Math.random());
					$("#errDiv").show();
					$("#err").html("系统异常");
				}
			});
		}
		
	    $(function (){
	       $("#loginForm").keydown(function(e){
	           var e = e || event, keycode = e.which || e.keyCode;
	           if (keycode == 13) {
	               login();
	            }
	       })
	    });
		
		jQuery(function($) {
			$(document).on('click', '.toolbar a[data-target]', function(e) {
				e.preventDefault();
				var target = $(this).data('target');
				$('.widget-box.visible').removeClass('visible');//hide others
				$(target).addClass('visible');//show target
			});
		});

		//you don't need this, just used for changing background
		jQuery(function($) {
			$('#btn-login-dark').on('click', function(e) {
				$('body').attr('class', 'login-layout');
				$('#id-text2').attr('class', 'white');
				$('#id-company-text').attr('class', 'blue');

				e.preventDefault();
			});
			$('#btn-login-light').on('click', function(e) {
				$('body').attr('class', 'login-layout light-login');
				$('#id-text2').attr('class', 'grey');
				$('#id-company-text').attr('class', 'blue');

				e.preventDefault();
			});
			$('#btn-login-blur').on('click', function(e) {
				$('body').attr('class', 'login-layout blur-login');
				$('#id-text2').attr('class', 'white');
				$('#id-company-text').attr('class', 'light-blue');

				e.preventDefault();
			});

		});
		
	</script>
</body>
</html>











数据监控设施


登录名密码 都是  admin


有需要的请下载源码:http://download.csdn.net/download/zhaokejin521/9990410

爱学习的请加QQ群:415777345 

















  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
SSM(Spring+SpringMVC+MyBatis)是一种Java Web开发框架,被广泛使用于企业级应用的开发中。Spring提供了依赖注入和面向切面编程的特性,Spring MVC是一种轻量级的Web框架,而MyBatis则是一种持久层框架,可以方便地操作数据库。 Layui是一个简单易用、高效轻量级的前端框架,可以帮助前端开发者快速搭建Web界面。Layui提供了丰富的UI组件和灵活的样式定制功能,能够帮助开发者实现页面的快速展示和交互。 Shiro是一个强大且易于使用的Java安全框架,提供了认证、授权、会话管理和加密等安全控制功能。Shiro能够帮助开发者轻松地实现用户身份验证和访问控制,提高系统的安全性。 综合上述三者,使用SSM框架可以简化Java Web的开发流程,通过Spring提供的依赖注入和面向切面编程,我们能够更好地管理和维护项目的各个组件。使用SpringMVC可以方便地开发出符合MVC设计模式的Web应用程序,而MyBatis则提供了对数据库的便捷访问,可以避免直接编写繁琐的SQL语句。 在前端方面,Layui的轻量级特性和丰富的UI组件能够加快前端开发的速度,使页面的搭建变得简单高效。 而使用Shiro可以保护我们的应用程序,通过身份验证和访问控制,可以确定用户的身份并限制其权限,提高系统的安全性。 总的来说,SSM、Layui和Shiro三者结合使用可以提高我们开发的效率和安全性,同时也能够提供用户友好的界面体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值