zoukankan      html  css  js  c++  java
  • Maven+Spring+Hibernate+Shiro+Mysql简单的demo框架(二)

    然后是项目下的文件:完整的项目请看  上一篇  Maven+Spring+Hibernate+Shiro+Mysql简单的demo框架(一)

    项目下的springmvc-servlet.xml配置文件:

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <beans xmlns="http://www.springframework.org/schema/beans"
     3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4        xmlns:aop="http://www.springframework.org/schema/aop"
     5        xmlns:context="http://www.springframework.org/schema/context"
     6        xmlns:tx="http://www.springframework.org/schema/tx"
     7        xmlns:util="http://www.springframework.org/schema/util" 
     8        xmlns:p="http://www.springframework.org/schema/p"
     9        xmlns:mvc="http://www.springframework.org/schema/mvc"
    10        xsi:schemaLocation="http://www.springframework.org/schema/beans
    11         http://www.springframework.org/schema/beans/spring-beans.xsd
    12          http://www.springframework.org/schema/mvc
    13          http://www.springframework.org/schema/mvc/spring-mvc.xsd
    14          http://www.springframework.org/schema/context
    15          http://www.springframework.org/schema/context/spring-context.xsd
    16          http://www.springframework.org/schema/aop
    17          http://www.springframework.org/schema/aop/spring-aop.xsd
    18          http://www.springframework.org/schema/tx
    19          http://www.springframework.org/schema/tx/spring-tx.xsd
    20          http://www.springframework.org/schema/util 
    21          http://www.springframework.org/schema/util/spring-util.xsd">
    22         <!-- AOP 注解支持 -->
    23     <aop:aspectj-autoproxy />
    24     <!-- 注解自动扫描 -->
    25     <context:annotation-config />
    26     <context:component-scan base-package="com.etop">
    27         <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    28     </context:component-scan>
    29       <!-- 启用spring mvc 注解-->
    30     <mvc:annotation-driven>
    31         <!-- 启动JSON格式的配置 -->
    32         <mvc:message-converters>  
    33         <bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
    34             <property name="supportedMediaTypes">  
    35                 <list>  
    36                     <value>text/html;charset=UTF-8</value>  <!-- 避免IE出现下载JSON文件的情况 -->
    37                 </list>  
    38             </property>    
    39         </bean>  
    40         </mvc:message-converters>
    41     </mvc:annotation-driven>
    42         <!-- 文件上传 -->
    43     <bean id="multipartResolver"
    44         class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    45         <property name="maxUploadSize" value="200000000" />
    46         <property name="defaultEncoding" value="utf-8" />
    47     </bean>
    48     <bean id="exceptionResolver"
    49         class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    50         <property name="exceptionMappings">
    51             <props>
    52                 <prop
    53                     key="org.springframework.web.multipart.MaxUploadSizeExceededException">error_fileupload</prop>
    54             </props>
    55         </property>
    56     </bean>
    57 </beans>

    项目的web.xml文件:

     1 <?xml version="1.0" encoding="UTF-8" ?>
     2 <web-app version="2.5"
     3          xmlns="http://java.sun.com/xml/ns/javaee"
     4          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     5          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
     6     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
     7     <display-name>Archetype Created Web Application</display-name>
     8 
     9 
    10     <!--过滤字符集-->
    11     <filter>
    12         <filter-name>encoding</filter-name>
    13         <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    14         <init-param>
    15             <param-name>encoding</param-name>
    16             <param-value>UTF-8</param-value>
    17         </init-param>
    18     </filter>
    19     <filter-mapping>
    20         <filter-name>encoding</filter-name>
    21         <url-pattern>/*</url-pattern>
    22     </filter-mapping>
    23     <!-- spring-orm-hibernate4的OpenSessionInViewFilter -->
    24     <filter>
    25         <filter-name>opensessioninview</filter-name>
    26         <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
    27     </filter>
    28     <filter-mapping>
    29         <filter-name>opensessioninview</filter-name>
    30         <url-pattern>/*</url-pattern>
    31     </filter-mapping>
    32 
    33     <!-- 配置springmvc servlet -->
    34     <servlet>
    35         <servlet-name>springmvc</servlet-name>
    36         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    37         <load-on-startup>1</load-on-startup>
    38     </servlet>
    39     <servlet-mapping>
    40         <servlet-name>springmvc</servlet-name>
    41         <!-- / 表示所有的请求都要经过此serlvet -->
    42         <url-pattern>*.html</url-pattern>
    43     </servlet-mapping>
    44 
    45     <!-- spring的监听器 -->
    46     <context-param>
    47         <param-name>contextConfigLocation</param-name>
    48         <param-value>classpath*:applicationContext.xml</param-value>
    49     </context-param>
    50     <listener>
    51         <listener-class>
    52             org.springframework.web.context.ContextLoaderListener
    53         </listener-class>
    54     </listener>
    55 
    56     <!-- Shiro配置 -->
    57     <filter>
    58         <filter-name>shiroFilter</filter-name>
    59         <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    60     </filter>
    61     <filter-mapping>
    62         <filter-name>shiroFilter</filter-name>
    63         <url-pattern>/*</url-pattern>
    64     </filter-mapping>
    65 
    66     <welcome-file-list>
    67         <welcome-file>login.html</welcome-file>
    68     </welcome-file-list>
    69 </web-app>  

    下面是相关的jsp页面:

    403.jsp

     1 <%@ page language="java"  pageEncoding="UTF-8"%>
     2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     3 <html>
     4 <head>
     5     <title>权限错误</title>
     6 </head>
     7 
     8 <body>
     9 <h1>403,You don't have permission to access / on this server</h1>
    10 
    11 </body>
    12 </html>

    functionList.jsp

      1 <%@ page language="java" pageEncoding="UTF-8" %>
      2 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
      3 <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
      4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      5 <html>
      6 <head>
      7 <%@ include file="path.jsp"%>
      8     <title>用户资源访问</title>
      9     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css">
     10     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css">
     11     <script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
     12     <script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
     13 </head>
     14 <body class="easyui-layout" style="overflow-y: hidden"  scroll="no">
     15     <table id="dg" title="用户资源访问" class="easyui-datagrid" style="1180px;height:540px;margin: 10px 5px 15px 20px;"
     16             url="function/get_functions.html"
     17             toolbar="#toolbar" pagination="true"
     18             rownumbers="true" fitColumns="true" singleSelect="true">
     19         <thead>
     20             <tr>
     21                 <th field="value" width="50">允许访问路径</th>
     22                 <th field="permission_id" width="50">访问权限</th>
     23                 <th field="role_id" width="50">角色</th>
     24                 <th field="type" width="50">类型</th>
     25             </tr>
     26         </thead>
     27     </table>
     28     <div id="toolbar">
     29         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加资源</a>
     30         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑资源</a>
     31         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除资源</a>
     32     </div>
     33     
     34     <div id="dlg" class="easyui-dialog" style="400px;height:280px;padding:10px 20px"
     35             closed="true" buttons="#dlg-buttons">
     36         <div class="ftitle">资源信息</div>
     37         <form id="fm" method="post" novalidate>
     38             <div class="fitem">
     39                 <label>允许访问路径:</label>
     40                 <input name="value" class="easyui-textbox" required="true">
     41             </div>
     42             <div class="fitem">
     43                 <label>访问权限:</label>
     44                 <input name="permission_id" class="easyui-textbox" required="true">
     45             </div>
     46             <div class="fitem">
     47                 <label>角色:</label>
     48                 <input name="role_id" class="easyui-textbox">
     49             </div>
     50             <div class="fitem">
     51                 <label>类型:</label>
     52                 <input name="type" class="easyui-textbox">
     53             </div>
     54         </form>
     55     </div>
     56     <div id="dlg-buttons">
     57         <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="90px">确定</a>
     58         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="90px">取消</a>
     59     </div>
     60     <script type="text/javascript">
     61         var url;
     62         function newUser(){
     63             $('#dlg').dialog('open').dialog('setTitle','增加资源');
     64             $('#fm').form('clear');
     65             url = 'function/add.html';
     66         }
     67         function editUser(){
     68             var row = $('#dg').datagrid('getSelected');
     69             if (row){
     70                 $('#dlg').dialog('open').dialog('setTitle','编辑资源');
     71                 $('#fm').form('load',row);
     72                 url = 'function/edit.html?id='+row.id;
     73             }
     74         }
     75         function saveUser(){
     76             $('#fm').form('submit',{
     77                 url: url,
     78                 onSubmit: function(){
     79                     return $(this).form('validate');
     80                 },
     81                 success: function(result){
     82                     var result = eval('('+result+')');
     83                     if (result.errorMsg){
     84                         $.messager.show({
     85                             title: '错误!',
     86                             msg: result.errorMsg
     87                         });
     88                     } else {
     89                         $('#dlg').dialog('close');        // close the dialog
     90                         $('#dg').datagrid('reload');    // reload the user data
     91                     }
     92                 }
     93             });
     94         }
     95         function destroyUser(){
     96             var row = $('#dg').datagrid('getSelected');
     97             if (row){
     98                 $.messager.confirm('提示','您确定删除该资源?',function(r){
     99                     if (r){
    100                         $.post('function/del.html',{id:row.id},function(result){
    101                             if (result.success){
    102                                 $('#dg').datagrid('reload');    // reload the user data
    103                             } else {
    104                                 $.messager.show({    // show error message
    105                                     title: '错误!',
    106                                     msg: result.errorMsg
    107                                 });
    108                             }
    109                         },'json');
    110                     }
    111                 });
    112             }
    113         }
    114     </script>
    115     <style type="text/css">
    116         #fm{
    117             margin:0;
    118             padding:10px 30px;
    119         }
    120         .ftitle{
    121             font-size:14px;
    122             font-weight:bold;
    123             padding:5px 0;
    124             margin-bottom:10px;
    125             border-bottom:1px solid #ccc;
    126         }
    127         .fitem{
    128             margin-bottom:5px;
    129         }
    130         .fitem label{
    131             display:inline-block;
    132             width:80px;
    133         }
    134         .fitem input{
    135             width:160px;
    136         }
    137     </style>
    138 </body>
    139 </html>

    login.jsp

      1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
      2 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
      3 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
      4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      5 <head>
      6 <%@ include file="path.jsp"%>
      7     <title>登录页面</title>
      8     <meta http-equiv="pragma" content="no-cache" />
      9     <meta http-equiv="cache-control" content="no-cache" />
     10     <meta http-equiv="expires" content="0" />
     11     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
     12     <meta http-equiv="description" content="This is my page" />
     13     <script type="text/javascript" src="${demoPath}static/js/md5.js"></script>
     14     <script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
     15     <script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
     16     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css" />
     17     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css" />
     18     <script type="text/javascript">
     19         window.onload = function() {
     20             //...
     21         }
     22        $(function(){
     23                 $("#verifyClick").bind('click',function(){
     24                     var url ='${demoPath}verifyCode.html?verifyCode=' + Math.random();
     25                     //$('#verifyCode').attr('src',url);
     26                     document.getElementById('verifyCode').setAttribute('src', url);
     27                 });
     28             });
     29        function submitForm(){
     30              var password = document.getElementById("password");
     31                //md5加密
     32              document.getElementById("password").value = hex_md5(password.value);
     33              document.user.submit();
     34         }
     35         function clearForm(){
     36             $('#ff').form('clear');
     37         }
     38     </script>
     39     <SCRIPT language=javascript type=text/javascript>
     40     function killerror()
     41     {
     42         return true;    
     43     }
     44     window.onerror=killerror;
     45     $(document).ready(function(){
     46         $('#username').focus();
     47         $('#ff').submit(function(){
     48             if($.trim($('#username').val())=='')
     49             {
     50                 $('#username').css("border-color","#ff9900");
     51                 $('#username').focus();
     52                 return false;
     53             }
     54             else
     55             {
     56                 $('#username').css("border-color","");
     57             }
     58 
     59             if($.trim($('#password').val())=='')
     60             {
     61                 $('#password').css("border-color","#ff9900");
     62                 $('#password').focus();
     63                 return false;
     64             }
     65             else
     66             {
     67                 $('#password').css("border-color","");
     68             }
     69             
     70             if($.trim($('#checkcode').val()).length!=4)
     71             {
     72                 $('#checkcode').css("border-color","#ff9900");
     73                 $('#checkcode').focus();
     74                 return false;
     75             }
     76             else
     77             {
     78                 $('#checkcode').css("border-color","");
     79             }
     80             return true;
     81         })
     82     });
     83 </SCRIPT>
     84     <style type="text/css">
     85 BODY {
     86     TEXT-ALIGN: center; PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #ddeef2; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
     87 }
     88 A:link {
     89     COLOR: #000000; TEXT-DECORATION: none
     90 }
     91 A:visited {
     92     COLOR: #000000; TEXT-DECORATION: none
     93 }
     94 A:hover {
     95     COLOR: #ff0000; TEXT-DECORATION: underline
     96 }
     97 A:active {
     98     TEXT-DECORATION: none
     99 }
    100 .input {
    101     BORDER-BOTTOM: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; LINE-HEIGHT: 20px; WIDTH: 182px; HEIGHT: 20px; BORDER-TOP: #ccc 1px solid; BORDER-RIGHT: #ccc 1px solid
    102 }
    103 .input1 {
    104     BORDER-BOTTOM: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; LINE-HEIGHT: 20px; WIDTH: 120px; HEIGHT: 20px; BORDER-TOP: #ccc 1px solid; BORDER-RIGHT: #ccc 1px solid
    105 }
    106 </style>
    107 </head>
    108 
    109 <body>
    110     <FORM id="ff" method=post name="user" action="login.html">
    111     <DIV></DIV>
    112     <TABLE style="MARGIN: auto; WIDTH: 100%; HEIGHT: 100%" border=0 cellSpacing=0 cellPadding=0>
    113           <TBODY>
    114               <TR><TD height=150>&nbsp;</TD></TR>
    115   <TR style="HEIGHT: 254px"> <TD>
    116          <DIV style="MARGIN: 0px auto; WIDTH: 936px"><IMG style="DISPLAY: block" src="${demoPath}static/image/body_03.jpg"> </DIV>
    117           <DIV style="BACKGROUND-COLOR: #278296">
    118           <DIV style="MARGIN: 0px auto; WIDTH: 936px">
    119           <DIV style="BACKGROUND: url(${demoPath}static/image/body_05.jpg) no-repeat; HEIGHT: 155px">
    120           <DIV style="TEXT-ALIGN: left; WIDTH: 265px; FLOAT: right; HEIGHT: 125px; _height: 95px">
    121       <TABLE border=0 cellSpacing=0 cellPadding=0 width="100%">
    122         <TBODY>
    123         <TR>
    124           <TD style="HEIGHT: 43px"><INPUT id=username class=input type=text name=username required="true"></TD></TR>
    125         <TR>
    126           <TD><INPUT id=password class=input type=password name=password required="true"></TD></TR>
    127             <TR>
    128               <TD style="HEIGHT: 50px"><INPUT id=checkcode required="true" class=yzm size=8 type=text name=checkcode> 
    129               <a style="text-align: center;" id="verifyClick" title="点击 刷新?" href="javascript:void(0);"> 
    130               <img style="65px;height:22px;" align="absmiddle" id="verifyCode" src="${demoPath}verifyCode.html" />
    131               </a>
    132             </TD></TR></TBODY></TABLE></DIV>
    133           <DIV style="HEIGHT: 1px; CLEAR: both"></DIV>
    134           <DIV style="WIDTH: 380px; FLOAT: right; CLEAR: both">
    135       <TABLE border=0 cellSpacing=0 cellPadding=0 width=300>
    136         <TBODY>
    137         <TR>
    138           <TD width=100 align=right><INPUT onclick="submitForm()"
    139             style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" 
    140             id=btnLogin src="${demoPath}static/image/btn1.jpg" 
    141             type=image name=btnLogin></TD>
    142           <TD width=100 align=middle><INPUT onclick="clearForm()"
    143             style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" 
    144             id=btnReset src="${demoPath}static/image/btn2.jpg" 
    145             type=image name=btnReset></TD></TR></TBODY></TABLE></DIV></DIV></DIV></DIV>
    146       <DIV style="MARGIN: 0px auto; WIDTH: 936px"><IMG 
    147       src="${demoPath}static/image/body_06.jpg"> </DIV></TD></TR>
    148           <TR style="HEIGHT: 30%">
    149             <TD>&nbsp;</TD></TR></TBODY></TABLE></FORM>
    150 </body>
    151 </html>  

    path.jsp

    1 <%
    2 String path = request.getContextPath();
    3 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    4 %>
    5 <base href="<%=basePath%>"/>
    6 <c:set var="demoPath" value="${pageContext.request.contextPath}/" scope="application" />

    perminssionList.jsp

      1 <%@ page language="java" pageEncoding="UTF-8" %>
      2 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
      3 <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
      4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      5 <html>
      6 <head>
      7 <%@ include file="path.jsp"%>
      8     <title>用户权限列表</title>
      9     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css">
     10     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css">
     11     <script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
     12     <script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
     13 </head>
     14 <body class="easyui-layout" style="overflow-y: hidden"  scroll="no">
     15     <table id="dg" title="权限用户列表" class="easyui-datagrid" style="1180px;height:540px;margin: 10px 5px 15px 20px;"
     16             url="permission/get_permissions.html"
     17             toolbar="#toolbar" pagination="true"
     18             rownumbers="true" fitColumns="true" singleSelect="true">
     19         <thead>
     20             <tr>
     21                 <th field="permissionname" width="50">权限方法</th>
     22                 <th field="role" width="50">用户密码</th>
     23                 <th field="phone" width="50">Phone</th>
     24                 <th field="email" width="50">Email</th>
     25             </tr>
     26         </thead>
     27     </table>
     28     <div id="toolbar">
     29         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加权限</a>
     30         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑权限</a>
     31         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除权限</a>
     32     </div>
     33     
     34     <div id="dlg" class="easyui-dialog" style="400px;height:280px;padding:10px 20px"
     35             closed="true" buttons="#dlg-buttons">
     36         <div class="ftitle">权限信息</div>
     37         <form id="fm" method="post" novalidate>
     38             <div class="fitem">
     39                 <label>权限方法:</label>
     40                 <input name="permissionname" class="easyui-textbox" required="true">
     41             </div>
     42             <div class="fitem">
     43                 <label>Last Name:</label>
     44                 <input name="password" class="easyui-textbox" required="true">
     45             </div>
     46             <div class="fitem">
     47                 <label>Phone:</label>
     48                 <input name="phone" class="easyui-textbox">
     49             </div>
     50             <div class="fitem">
     51                 <label>Email:</label>
     52                 <input name="email" class="easyui-textbox" validType="email">
     53             </div>
     54         </form>
     55     </div>
     56     <div id="dlg-buttons">
     57         <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="90px">确定</a>
     58         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="90px">取消</a>
     59     </div>
     60     <script type="text/javascript">
     61         var url;
     62         function newUser(){
     63             $('#dlg').dialog('open').dialog('setTitle','添加权限');
     64             $('#fm').form('clear');
     65             url = 'permission/add.html';
     66         }
     67         function editUser(){
     68             var row = $('#dg').datagrid('getSelected');
     69             if (row){
     70                 $('#dlg').dialog('open').dialog('setTitle','编辑权限');
     71                 $('#fm').form('load',row);
     72                 url = 'permission/edit.html?id='+row.id;
     73             }
     74         }
     75         function saveUser(){
     76             $('#fm').form('submit',{
     77                 url: url,
     78                 onSubmit: function(){
     79                     return $(this).form('validate');
     80                 },
     81                 success: function(result){
     82                     var result = eval('('+result+')');
     83                     if (result.errorMsg){
     84                         $.messager.show({
     85                             title: '错误!',
     86                             msg: result.errorMsg
     87                         });
     88                     } else {
     89                         $('#dlg').dialog('close');        // close the dialog
     90                         $('#dg').datagrid('reload');    // reload the user data
     91                     }
     92                 }
     93             });
     94         }
     95         function destroyUser(){
     96             var row = $('#dg').datagrid('getSelected');
     97             if (row){
     98                 $.messager.confirm('提示','您确定删除该权限?',function(r){
     99                     if (r){
    100                         $.post('permission/del.html',{id:row.id},function(result){
    101                             if (result.success){
    102                                 $('#dg').datagrid('reload');    // reload the user data
    103                             } else {
    104                                 $.messager.show({    // show error message
    105                                     title: '错误!',
    106                                     msg: result.errorMsg
    107                                 });
    108                             }
    109                         },'json');
    110                     }
    111                 });
    112             }
    113         }
    114     </script>
    115     <style type="text/css">
    116         #fm{
    117             margin:0;
    118             padding:10px 30px;
    119         }
    120         .ftitle{
    121             font-size:14px;
    122             font-weight:bold;
    123             padding:5px 0;
    124             margin-bottom:10px;
    125             border-bottom:1px solid #ccc;
    126         }
    127         .fitem{
    128             margin-bottom:5px;
    129         }
    130         .fitem label{
    131             display:inline-block;
    132             width:80px;
    133         }
    134         .fitem input{
    135             width:160px;
    136         }
    137     </style>
    138 </body>
    139 </html>

    roleList.jsp

      1 <%@ page language="java" pageEncoding="UTF-8" %>
      2 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
      3 <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
      4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      5 <html>
      6 <head>
      7 <%@ include file="path.jsp"%>
      8     <title>角色列表</title>
      9     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css">
     10     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css">
     11     <script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
     12     <script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
     13 </head>
     14 <body class="easyui-layout" style="overflow-y: hidden"  scroll="no">
     15     <table id="dg" title="角色列表" class="easyui-datagrid" style="1180px;height:540px;margin: 10px 5px 15px 20px;"
     16             url="role/get_roles.html"
     17             toolbar="#toolbar" pagination="true"
     18             rownumbers="true" fitColumns="true" singleSelect="true">
     19         <thead>
     20             <tr>
     21                 <th field="rolename" width="50">角色名</th>
     22                 <th field="description" width="50">角色描述</th>
     23                 <th field="email" width="50">Email</th>
     24             </tr>
     25         </thead>
     26     </table>
     27     <div id="toolbar">
     28         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加角色</a>
     29         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑角色</a>
     30         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除角色</a>
     31     </div>
     32     
     33     <div id="dlg" class="easyui-dialog" style="400px;height:280px;padding:10px 20px"
     34             closed="true" buttons="#dlg-buttons">
     35         <div class="ftitle">角色信息</div>
     36         <form id="fm" method="post" novalidate>
     37             <div class="fitem">
     38                 <label>角色名称:</label>
     39                 <input name="rolename" class="easyui-textbox" required="true">
     40             </div>
     41             <div class="fitem">
     42                 <label>角色描述:</label>
     43                 <input name="description" class="easyui-textbox" required="true">
     44             </div>
     45         </form>
     46     </div>
     47     <div id="dlg-buttons">
     48         <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="90px">确定</a>
     49         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="90px">取消</a>
     50     </div>
     51     <script type="text/javascript">
     52         var url;
     53         function newUser(){
     54             $('#dlg').dialog('open').dialog('setTitle','增加角色');
     55             $('#fm').form('clear');
     56             url = 'role/add.html';
     57         }
     58         function editUser(){
     59             var row = $('#dg').datagrid('getSelected');
     60             if (row){
     61                 $('#dlg').dialog('open').dialog('setTitle','编辑角色');
     62                 $('#fm').form('load',row);
     63                 url = 'role/edit.html?id='+row.id;
     64             }
     65         }
     66         function saveUser(){
     67             $('#fm').form('submit',{
     68                 url: url,
     69                 onSubmit: function(){
     70                     return $(this).form('validate');
     71                 },
     72                 success: function(result){
     73                     var result = eval('('+result+')');
     74                     if (result.errorMsg){
     75                         $.messager.show({
     76                             title: '错误',
     77                             msg: result.errorMsg
     78                         });
     79                     } else {
     80                         $('#dlg').dialog('close');        // close the dialog
     81                         $('#dg').datagrid('reload');    // reload the user data
     82                     }
     83                 }
     84             });
     85         }
     86         function destroyUser(){
     87             var row = $('#dg').datagrid('getSelected');
     88             if (row){
     89                 $.messager.confirm('提示','您确定要删除该角色?',function(r){
     90                     if (r){
     91                         $.post('role/del.html',{id:row.id},function(result){
     92                             if (result.success){
     93                                 $('#dg').datagrid('reload');    // reload the user data
     94                             } else {
     95                                 $.messager.show({    // show error message
     96                                     title: '错误!',
     97                                     msg: result.errorMsg
     98                                 });
     99                             }
    100                         },'json');
    101                     }
    102                 });
    103             }
    104         }
    105     </script>
    106     <style type="text/css">
    107         #fm{
    108             margin:0;
    109             padding:10px 30px;
    110         }
    111         .ftitle{
    112             font-size:14px;
    113             font-weight:bold;
    114             padding:5px 0;
    115             margin-bottom:10px;
    116             border-bottom:1px solid #ccc;
    117         }
    118         .fitem{
    119             margin-bottom:5px;
    120         }
    121         .fitem label{
    122             display:inline-block;
    123             width:80px;
    124         }
    125         .fitem input{
    126             width:160px;
    127         }
    128     </style>
    129 </body>
    130 </html>

    success.jsp

     1 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
     2 <html>
     3 <head>
     4     <title></title>
     5 </head>
     6 <body>
     7     url权限控制:
     8     有此权限功能
     9 </body>
    10 </html>

    user.jsp

      1 <%@ page language="java" pageEncoding="UTF-8" %>
      2 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
      3 <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
      4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      5 <html>
      6 <head id="Head1">
      7 <%@ include file="path.jsp"%>
      8     <title>用户列表</title>
      9     <script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
     10     <script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
     11     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css" />
     12     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css" />
     13     <link rel="stylesheet" type="text/css" href="${demoPath}static/css/default.css" />
     14     <%-- <script type="text/javascript" src='${demoPath}static/js/outlook2.js'> </script> --%>
     15     <script type="text/javascript" src='${demoPath}static/js/publicmethod.js'> </script>
     16     <style type="text/css">
     17     .cs-navi-tab {
     18     padding: 5px;
     19     }
     20     .cs-navi-tab:hover {
     21     padding:5px;
     22     text-decoration:none;
     23     font-size: 16px;
     24     color: black;
     25     }
     26     </style>
     27     <script type="text/javascript">
     28         //设置登录窗口
     29         function openPwd() {
     30             $('#w').window({
     31                 title: '修改密码',
     32                  300,
     33                 modal: true,
     34                 shadow: true,
     35                 closed: true,
     36                 height: 160,
     37                 resizable:false
     38             });
     39         }
     40         //关闭登录窗口
     41         function closePwd() {
     42             $('#w').window('close');
     43         }
     44         //修改密码
     45         function serverLogin() {
     46             var $newpass = $('#txtNewPass');
     47             var $rePass = $('#txtRePass');
     48 
     49             if ($newpass.val() == '') {
     50                 msgShow('系统提示', '请输入密码!', 'warning');
     51                 return false;
     52             }
     53             if ($rePass.val() == '') {
     54                 msgShow('系统提示', '请在一次输入密码!', 'warning');
     55                 return false;
     56             }
     57 
     58             if ($newpass.val() != $rePass.val()) {
     59                 msgShow('系统提示', '两次密码不一至!请重新输入', 'warning');
     60                 return false;
     61             }
     62 
     63             $.post('/ajax/editpassword.ashx?newpass=' + $newpass.val(), function(msg) {
     64                 msgShow('系统提示', '恭喜,密码修改成功!<br>您的新密码为:' + msg, 'info');
     65                 $newpass.val('');
     66                 $rePass.val('');
     67                 close();
     68             })
     69             
     70         }
     71 
     72         $(function() {
     73 
     74             openPwd();
     75 
     76             $('#editpass').click(function() {
     77                 $('#w').window('open');
     78             });
     79 
     80             $('#btnEp').click(function() {
     81                 serverLogin();
     82             })
     83 
     84             $('#btnCancel').click(function(){closePwd();})
     85 
     86             $('#loginOut').click(function() {
     87                 $.messager.confirm('系统提示', '您确定要退出本次登录吗?', function(r) {
     88 
     89                     if (r) {
     90                         location.href = '/ajax/loginout.ashx';
     91                     }
     92                 });
     93             })
     94         });
     95     </script>
     96 </head>
     97 <body class="easyui-layout" style="overflow-y: hidden"  scroll="no">
     98 <noscript>
     99 <div style=" position:absolute; z-index:100000; height:2046px;top:0px;left:0px; 100%; background:white; text-align:center;">
    100     <img src="${demoPath}static/image/noscript.gif" alt='抱歉,请开启脚本支持!' />
    101 </div></noscript>
    102     <div region="north" split="true" border="false" style="overflow: hidden; height: 30px;
    103         background: url(${demoPath}static/image/layout-browser-hd-bg.gif) #7f99be repeat-x center 50%;
    104         line-height: 20px;color: #fff; font-family: Verdana, 微软雅黑,黑体">
    105         <span style="float:right; padding-right:20px;" class="head">欢迎 用户登录 <a id="editpass">修改密码</a> <a href="#" id="loginOut">安全退出</a></span>
    106         <span style="padding-left:10px; font-size: 16px; "><img src="${demoPath}static/image/blocks.gif" width="20" height="20" align="absmiddle" />VCS后台管理</span>
    107     </div>
    108     <div region="south" split="true" style="height: 30px; background: #D2E0F2; ">
    109         <div class="footer">By 天源迪科信息有限公司</div>
    110     </div>
    111     <div region="west" hide="true" split="true" title="导航菜单" style="180px;" id="west">
    112     <div id="nav" class="easyui-accordion" fit="true" border="false">
    113         <div title="系统管理">
    114             <a href="javascript:void(0);" src="user/userList.html" iconCls="icon-user" class="cs-navi-tab">用户管理</a></p>
    115             <a href="javascript:void(0);" src="role/roleList.html" class="cs-navi-tab">角色管理</a></p>
    116             <a href="javascript:void(0);" src="permission/permissonList.html" class="cs-navi-tab">权限设置</a></p>
    117             <a href="javascript:void(0);" src="function/functionList.html" class="cs-navi-tab">资源管理</a></p>
    118             <a href="javascript:void(0);" src="system/log.html" class="cs-navi-tab">系统日志</a></p>
    119         </div>
    120         <div title="商户管理">
    121             <a href="javascript:void(0);" src="user/userList.html" class="cs-navi-tab">商户管理</a></p>
    122             <a href="javascript:void(0);" src="role/roleList.html" class="cs-navi-tab">商户管理</a></p>
    123             <a href="javascript:void(0);" src="permission/permissonList.html" class="cs-navi-tab">商户管理</a></p>
    124             <a href="javascript:void(0);" src="function/functionList.html" class="cs-navi-tab">商户管理</a></p>
    125             <a href="javascript:void(0);" src="system/log.html" class="cs-navi-tab">商户管理</a></p>
    126         </div>
    127             </div>
    128     </div>
    129     <div id="mainPanle" region="center" style="background: #eee; overflow-y:hidden">
    130         <div id="tabs" class="easyui-tabs"  fit="true" border="false" >
    131             <div title="欢迎使用" style="padding:20px;overflow:hidden; color:red; " >
    132                 <h1 style="font-size:24px;">* 作者:天源迪科信息有限公司</h1>
    133 <h1 style="font-size:24px;">* BLOG: <a style="font-size:24px;color:green;" href="https://github.com/liuren">天源迪科信息有限公司</a></h1>
    134 <h1 style="font-size:24px;">* 技术支持QQ:393993507</h1>
    135             </div>
    136         </div>
    137     </div>
    138     <!--修改密码窗口-->
    139     <div id="w" class="easyui-window" title="修改密码" collapsible="false" minimizable="false"
    140         maximizable="false" icon="icon-save"  style=" 300px; height: 150px; padding: 5px;
    141         background: #fafafa;">
    142         <div class="easyui-layout" fit="true">
    143             <div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
    144                 <table cellpadding=3>
    145                     <tr>
    146                         <td>新密码:</td>
    147                         <td><input id="txtNewPass" type="Password" class="txt01" /></td>
    148                     </tr>
    149                     <tr>
    150                         <td>确认密码:</td>
    151                         <td><input id="txtRePass" type="Password" class="txt01" /></td>
    152                     </tr>
    153                 </table>
    154             </div>
    155             <div region="south" border="false" style="text-align: right; height: 30px; line-height: 30px;">
    156                 <a id="btnEp" class="easyui-linkbutton" icon="icon-ok" href="javascript:void(0)" >
    157                     确定</a> <a id="btnCancel" class="easyui-linkbutton" icon="icon-cancel" href="javascript:void(0)">取消</a>
    158             </div>
    159         </div>
    160     </div>
    161 
    162     <div id="mm" class="easyui-menu" style="150px;">
    163         <div id="mm-tabupdate">刷新</div>
    164         <div class="menu-sep"></div>
    165         <div id="mm-tabclose">关闭</div>
    166         <div id="mm-tabcloseall">全部关闭</div>
    167         <div id="mm-tabcloseother">除此之外全部关闭</div>
    168         <div class="menu-sep"></div>
    169         <div id="mm-tabcloseright">当前页右侧全部关闭</div>
    170         <div id="mm-tabcloseleft">当前页左侧全部关闭</div>
    171         <div class="menu-sep"></div>
    172         <div id="mm-exit">退出</div>
    173     </div>
    174 </body>
    175 </html>

    userList.jsp

      1 <%@ page language="java" pageEncoding="UTF-8" %>
      2 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
      3 <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
      4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      5 <html>
      6 <head>
      7 <%@ include file="path.jsp"%>
      8     <title>用户列表</title>
      9     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css">
     10     <link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css">
     11     <script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
     12     <script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
     13 </head>
     14 <body class="easyui-layout" style="overflow-y: hidden"  scroll="no">
     15     <table id="dg" title="用户列表" class="easyui-datagrid" style="1180px;height:540px;margin: 10px 5px 15px 20px;"
     16             url="user/get_users.html"
     17             toolbar="#toolbar" pagination="true"
     18             rownumbers="true" fitColumns="true" singleSelect="true">
     19         <thead>
     20             <tr>
     21                 <th field="username" width="50">用户名</th>
     22                 <th field="password" width="50">用户密码</th>
     23                 <th field="phone" width="50">手机号</th>
     24                 <th field="email" width="50">电子邮件</th>
     25             </tr>
     26         </thead>
     27     </table>
     28     <div id="toolbar">
     29         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加用户</a>
     30         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑用户</a>
     31         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除用户</a>
     32     </div>
     33     
     34     <div id="dlg" class="easyui-dialog" style="400px;height:280px;padding:10px 20px"
     35             closed="true" buttons="#dlg-buttons">
     36         <div class="ftitle">用户信息</div>
     37         <form id="fm" method="post" novalidate>
     38             <div class="fitem">
     39                 <label>用户名:</label>
     40                 <input name="username" class="easyui-textbox" required="true">
     41             </div>
     42             <div class="fitem">
     43                 <label>&nbsp;码:</label>
     44                 <input name="password" class="easyui-textbox" required="true">
     45             </div>
     46             <div class="fitem">
     47                 <label>手机号:</label>
     48                 <input name="phone" class="easyui-textbox">
     49             </div>
     50             <div class="fitem">
     51                 <label>电子邮箱:</label>
     52                 <input name="email" class="easyui-textbox" validType="email">
     53             </div>
     54         </form>
     55     </div>
     56     <div id="dlg-buttons">
     57         <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="90px">确定</a>
     58         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="90px">取消</a>
     59     </div>
     60     <script type="text/javascript">
     61         var url;
     62         function newUser(){
     63             $('#dlg').dialog('open').dialog('setTitle','增加用户');
     64             $('#fm').form('clear');
     65             url = 'user/add.html';
     66         }
     67         function editUser(){
     68             var row = $('#dg').datagrid('getSelected');
     69             if (row){
     70                 $('#dlg').dialog('open').dialog('setTitle','编辑用户');
     71                 $('#fm').form('load',row);
     72                 url = 'user/edit.html?id='+row.id;
     73             }
     74         }
     75         function saveUser(){
     76             $('#fm').form('submit',{
     77                 url: url,
     78                 onSubmit: function(){
     79                     return $(this).form('validate');
     80                 },
     81                 success: function(result){
     82                     var result = eval('('+result+')');
     83                     if (result.errorMsg){
     84                         $.messager.show({
     85                             title: '保存失败!',
     86                             msg: result.errorMsg
     87                         });
     88                     } else {
     89                         $('#dlg').dialog('close');        // close the dialog
     90                         $('#dg').datagrid('reload');    // reload the user data
     91                     }
     92                 }
     93             });
     94         }
     95         function destroyUser(){
     96             var row = $('#dg').datagrid('getSelected');
     97             if (row){
     98                 $.messager.confirm('提示','你确定要删除用户?',function(r){
     99                     if (r){
    100                         $.post('user/del.html',{id:row.id},function(result){
    101                             if (result.success){
    102                                 $('#dg').datagrid('reload');    // reload the user data
    103                             } else {
    104                                 $.messager.show({    // show error message
    105                                     title: '删除失败!',
    106                                     msg: result.errorMsg
    107                                 });
    108                             }
    109                         },'json');
    110                     }
    111                 });
    112             }
    113         }
    114     </script>
    115     <style type="text/css">
    116         #fm{
    117             margin:0;
    118             padding:10px 30px;
    119         }
    120         .ftitle{
    121             font-size:14px;
    122             font-weight:bold;
    123             padding:5px 0;
    124             margin-bottom:10px;
    125             border-bottom:1px solid #ccc;
    126         }
    127         .fitem{
    128             margin-bottom:5px;
    129         }
    130         .fitem label{
    131             display:inline-block;
    132             width:80px;
    133         }
    134         .fitem input{
    135             width:160px;
    136         }
    137     </style>
    138 </body>
    139 </html>

    下面是项目的说明文件 read.md文件:

    1 1.该项目是使用的Maven+SpringMVC+Hibernate+Mysql+easyUI+shiro
    2 2.该项目启动器是jetty
    3 3.run as 项目然后 输入 jetty:run  运行即可
    4 4.用户名: admin1 admin2 admin3 admin4 密码全部是:000000

    相关源代码文件存放到了百度云盘:

    http://pan.baidu.com/s/1boiRIEj

  • 相关阅读:
    [数据结构]图的DFS和BFS的两种实现方式
    [算法]两个栈实现一个队列
    [数据结构]手动实现队列
    [数据结构]手动实现栈
    [数据结构]手动实现单链表
    Hive分组取Top K数据
    HBase解决海量图片存储方案
    非结构化数据存储方案
    头条面试题之实现两个线程轮流打印字符串
    [算法]最大连续子数组和,最长重复子串,最长无重复字符子串
  • 原文地址:https://www.cnblogs.com/lr393993507/p/5257225.html
Copyright © 2011-2022 走看看