然后是项目下的文件:完整的项目请看 上一篇 Maven+Spring+Hibernate+Shiro+Mysql简单的demo框架(一)
项目下的springmvc-servlet.xml配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<!-- AOP 注解支持 -->
<aop:aspectj-autoproxy />
<!-- 注解自动扫描 -->
<context:annotation-config />
<context:component-scan base-package="com.etop">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 启用spring mvc 注解-->
<mvc:annotation-driven>
<!-- 启动JSON格式的配置 -->
<mvc:message-converters>
<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value> <!-- 避免IE出现下载JSON文件的情况 -->
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- 文件上传 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="200000000" />
<property name="defaultEncoding" value="utf-8" />
</bean>
<bean id="exceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop
key="org.springframework.web.multipart.MaxUploadSizeExceededException">error_fileupload</prop>
</props>
</property>
</bean>
</beans>
项目的web.xml文件:
<?xml version="1.0" encoding="UTF-8" ?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Archetype Created Web Application</display-name> <!--过滤字符集-->
<filter>
<filter-name>encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- spring-orm-hibernate4的OpenSessionInViewFilter -->
<filter>
<filter-name>opensessioninview</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>opensessioninview</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 配置springmvc servlet -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<!-- / 表示所有的请求都要经过此serlvet -->
<url-pattern>*.html</url-pattern>
</servlet-mapping> <!-- spring的监听器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <!-- Shiro配置 -->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
</web-app>
下面是相关的jsp页面:
403.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>权限错误</title>
</head> <body>
<h1>403,You don't have permission to access / on this server</h1> </body>
</html>
functionList.jsp
<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ include file="path.jsp"%>
<title>用户资源访问</title>
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css">
<script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
<table id="dg" title="用户资源访问" class="easyui-datagrid" style="width:1180px;height:540px;margin: 10px 5px 15px 20px;"
url="function/get_functions.html"
toolbar="#toolbar" pagination="true"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th field="value" width="50">允许访问路径</th>
<th field="permission_id" width="50">访问权限</th>
<th field="role_id" width="50">角色</th>
<th field="type" width="50">类型</th>
</tr>
</thead>
</table>
<div id="toolbar">
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加资源</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑资源</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除资源</a>
</div> <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
closed="true" buttons="#dlg-buttons">
<div class="ftitle">资源信息</div>
<form id="fm" method="post" novalidate>
<div class="fitem">
<label>允许访问路径:</label>
<input name="value" class="easyui-textbox" required="true">
</div>
<div class="fitem">
<label>访问权限:</label>
<input name="permission_id" class="easyui-textbox" required="true">
</div>
<div class="fitem">
<label>角色:</label>
<input name="role_id" class="easyui-textbox">
</div>
<div class="fitem">
<label>类型:</label>
<input name="type" class="easyui-textbox">
</div>
</form>
</div>
<div id="dlg-buttons">
<a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">确定</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">取消</a>
</div>
<script type="text/javascript">
var url;
function newUser(){
$('#dlg').dialog('open').dialog('setTitle','增加资源');
$('#fm').form('clear');
url = 'function/add.html';
}
function editUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$('#dlg').dialog('open').dialog('setTitle','编辑资源');
$('#fm').form('load',row);
url = 'function/edit.html?id='+row.id;
}
}
function saveUser(){
$('#fm').form('submit',{
url: url,
onSubmit: function(){
return $(this).form('validate');
},
success: function(result){
var result = eval('('+result+')');
if (result.errorMsg){
$.messager.show({
title: '错误!',
msg: result.errorMsg
});
} else {
$('#dlg').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the user data
}
}
});
}
function destroyUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$.messager.confirm('提示','您确定删除该资源?',function(r){
if (r){
$.post('function/del.html',{id:row.id},function(result){
if (result.success){
$('#dg').datagrid('reload'); // reload the user data
} else {
$.messager.show({ // show error message
title: '错误!',
msg: result.errorMsg
});
}
},'json');
}
});
}
}
</script>
<style type="text/css">
#fm{
margin:0;
padding:10px 30px;
}
.ftitle{
font-size:14px;
font-weight:bold;
padding:5px 0;
margin-bottom:10px;
border-bottom:1px solid #ccc;
}
.fitem{
margin-bottom:5px;
}
.fitem label{
display:inline-block;
width:80px;
}
.fitem input{
width:160px;
}
</style>
</body>
</html>
login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
<%@ include file="path.jsp"%>
<title>登录页面</title>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
<meta http-equiv="description" content="This is my page" />
<script type="text/javascript" src="${demoPath}static/js/md5.js"></script>
<script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css" />
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css" />
<script type="text/javascript">
window.onload = function() {
//...
}
$(function(){
$("#verifyClick").bind('click',function(){
var url ='${demoPath}verifyCode.html?verifyCode=' + Math.random();
//$('#verifyCode').attr('src',url);
document.getElementById('verifyCode').setAttribute('src', url);
});
});
function submitForm(){
var password = document.getElementById("password");
//md5加密
document.getElementById("password").value = hex_md5(password.value);
document.user.submit();
}
function clearForm(){
$('#ff').form('clear');
}
</script>
<SCRIPT language=javascript type=text/javascript>
function killerror()
{
return true;
}
window.onerror=killerror;
$(document).ready(function(){
$('#username').focus();
$('#ff').submit(function(){
if($.trim($('#username').val())=='')
{
$('#username').css("border-color","#ff9900");
$('#username').focus();
return false;
}
else
{
$('#username').css("border-color","");
} if($.trim($('#password').val())=='')
{
$('#password').css("border-color","#ff9900");
$('#password').focus();
return false;
}
else
{
$('#password').css("border-color","");
} if($.trim($('#checkcode').val()).length!=4)
{
$('#checkcode').css("border-color","#ff9900");
$('#checkcode').focus();
return false;
}
else
{
$('#checkcode').css("border-color","");
}
return true;
})
});
</SCRIPT>
<style type="text/css">
BODY {
TEXT-ALIGN: center; PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #ddeef2; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
}
A:link {
COLOR: #000000; TEXT-DECORATION: none
}
A:visited {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #ff0000; TEXT-DECORATION: underline
}
A:active {
TEXT-DECORATION: none
}
.input {
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
}
.input1 {
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
}
</style>
</head> <body>
<FORM id="ff" method=post name="user" action="login.html">
<DIV></DIV>
<TABLE style="MARGIN: auto; WIDTH: 100%; HEIGHT: 100%" border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR><TD height=150> </TD></TR>
<TR style="HEIGHT: 254px"> <TD>
<DIV style="MARGIN: 0px auto; WIDTH: 936px"><IMG style="DISPLAY: block" src="${demoPath}static/image/body_03.jpg"> </DIV>
<DIV style="BACKGROUND-COLOR: #278296">
<DIV style="MARGIN: 0px auto; WIDTH: 936px">
<DIV style="BACKGROUND: url(${demoPath}static/image/body_05.jpg) no-repeat; HEIGHT: 155px">
<DIV style="TEXT-ALIGN: left; WIDTH: 265px; FLOAT: right; HEIGHT: 125px; _height: 95px">
<TABLE border=0 cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD style="HEIGHT: 43px"><INPUT id=username class=input type=text name=username required="true"></TD></TR>
<TR>
<TD><INPUT id=password class=input type=password name=password required="true"></TD></TR>
<TR>
<TD style="HEIGHT: 50px"><INPUT id=checkcode required="true" class=yzm size=8 type=text name=checkcode>
<a style="text-align: center;" id="verifyClick" title="点击 刷新?" href="javascript:void(0);">
<img style="width:65px;height:22px;" align="absmiddle" id="verifyCode" src="${demoPath}verifyCode.html" />
</a>
</TD></TR></TBODY></TABLE></DIV>
<DIV style="HEIGHT: 1px; CLEAR: both"></DIV>
<DIV style="WIDTH: 380px; FLOAT: right; CLEAR: both">
<TABLE border=0 cellSpacing=0 cellPadding=0 width=300>
<TBODY>
<TR>
<TD width=100 align=right><INPUT onclick="submitForm()"
style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px"
id=btnLogin src="${demoPath}static/image/btn1.jpg"
type=image name=btnLogin></TD>
<TD width=100 align=middle><INPUT onclick="clearForm()"
style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px"
id=btnReset src="${demoPath}static/image/btn2.jpg"
type=image name=btnReset></TD></TR></TBODY></TABLE></DIV></DIV></DIV></DIV>
<DIV style="MARGIN: 0px auto; WIDTH: 936px"><IMG
src="${demoPath}static/image/body_06.jpg"> </DIV></TD></TR>
<TR style="HEIGHT: 30%">
<TD> </TD></TR></TBODY></TABLE></FORM>
</body>
</html>
path.jsp
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<base href="<%=basePath%>"/>
<c:set var="demoPath" value="${pageContext.request.contextPath}/" scope="application" />
perminssionList.jsp
<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ include file="path.jsp"%>
<title>用户权限列表</title>
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css">
<script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
<table id="dg" title="权限用户列表" class="easyui-datagrid" style="width:1180px;height:540px;margin: 10px 5px 15px 20px;"
url="permission/get_permissions.html"
toolbar="#toolbar" pagination="true"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th field="permissionname" width="50">权限方法</th>
<th field="role" width="50">用户密码</th>
<th field="phone" width="50">Phone</th>
<th field="email" width="50">Email</th>
</tr>
</thead>
</table>
<div id="toolbar">
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加权限</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑权限</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除权限</a>
</div> <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
closed="true" buttons="#dlg-buttons">
<div class="ftitle">权限信息</div>
<form id="fm" method="post" novalidate>
<div class="fitem">
<label>权限方法:</label>
<input name="permissionname" class="easyui-textbox" required="true">
</div>
<div class="fitem">
<label>Last Name:</label>
<input name="password" class="easyui-textbox" required="true">
</div>
<div class="fitem">
<label>Phone:</label>
<input name="phone" class="easyui-textbox">
</div>
<div class="fitem">
<label>Email:</label>
<input name="email" class="easyui-textbox" validType="email">
</div>
</form>
</div>
<div id="dlg-buttons">
<a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">确定</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">取消</a>
</div>
<script type="text/javascript">
var url;
function newUser(){
$('#dlg').dialog('open').dialog('setTitle','添加权限');
$('#fm').form('clear');
url = 'permission/add.html';
}
function editUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$('#dlg').dialog('open').dialog('setTitle','编辑权限');
$('#fm').form('load',row);
url = 'permission/edit.html?id='+row.id;
}
}
function saveUser(){
$('#fm').form('submit',{
url: url,
onSubmit: function(){
return $(this).form('validate');
},
success: function(result){
var result = eval('('+result+')');
if (result.errorMsg){
$.messager.show({
title: '错误!',
msg: result.errorMsg
});
} else {
$('#dlg').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the user data
}
}
});
}
function destroyUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$.messager.confirm('提示','您确定删除该权限?',function(r){
if (r){
$.post('permission/del.html',{id:row.id},function(result){
if (result.success){
$('#dg').datagrid('reload'); // reload the user data
} else {
$.messager.show({ // show error message
title: '错误!',
msg: result.errorMsg
});
}
},'json');
}
});
}
}
</script>
<style type="text/css">
#fm{
margin:0;
padding:10px 30px;
}
.ftitle{
font-size:14px;
font-weight:bold;
padding:5px 0;
margin-bottom:10px;
border-bottom:1px solid #ccc;
}
.fitem{
margin-bottom:5px;
}
.fitem label{
display:inline-block;
width:80px;
}
.fitem input{
width:160px;
}
</style>
</body>
</html>
roleList.jsp
<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ include file="path.jsp"%>
<title>角色列表</title>
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css">
<script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
<table id="dg" title="角色列表" class="easyui-datagrid" style="width:1180px;height:540px;margin: 10px 5px 15px 20px;"
url="role/get_roles.html"
toolbar="#toolbar" pagination="true"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th field="rolename" width="50">角色名</th>
<th field="description" width="50">角色描述</th>
<th field="email" width="50">Email</th>
</tr>
</thead>
</table>
<div id="toolbar">
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加角色</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑角色</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除角色</a>
</div> <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
closed="true" buttons="#dlg-buttons">
<div class="ftitle">角色信息</div>
<form id="fm" method="post" novalidate>
<div class="fitem">
<label>角色名称:</label>
<input name="rolename" class="easyui-textbox" required="true">
</div>
<div class="fitem">
<label>角色描述:</label>
<input name="description" class="easyui-textbox" required="true">
</div>
</form>
</div>
<div id="dlg-buttons">
<a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">确定</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">取消</a>
</div>
<script type="text/javascript">
var url;
function newUser(){
$('#dlg').dialog('open').dialog('setTitle','增加角色');
$('#fm').form('clear');
url = 'role/add.html';
}
function editUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$('#dlg').dialog('open').dialog('setTitle','编辑角色');
$('#fm').form('load',row);
url = 'role/edit.html?id='+row.id;
}
}
function saveUser(){
$('#fm').form('submit',{
url: url,
onSubmit: function(){
return $(this).form('validate');
},
success: function(result){
var result = eval('('+result+')');
if (result.errorMsg){
$.messager.show({
title: '错误',
msg: result.errorMsg
});
} else {
$('#dlg').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the user data
}
}
});
}
function destroyUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$.messager.confirm('提示','您确定要删除该角色?',function(r){
if (r){
$.post('role/del.html',{id:row.id},function(result){
if (result.success){
$('#dg').datagrid('reload'); // reload the user data
} else {
$.messager.show({ // show error message
title: '错误!',
msg: result.errorMsg
});
}
},'json');
}
});
}
}
</script>
<style type="text/css">
#fm{
margin:0;
padding:10px 30px;
}
.ftitle{
font-size:14px;
font-weight:bold;
padding:5px 0;
margin-bottom:10px;
border-bottom:1px solid #ccc;
}
.fitem{
margin-bottom:5px;
}
.fitem label{
display:inline-block;
width:80px;
}
.fitem input{
width:160px;
}
</style>
</body>
</html>
success.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
url权限控制:
有此权限功能
</body>
</html>
user.jsp
<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head id="Head1">
<%@ include file="path.jsp"%>
<title>用户列表</title>
<script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css" />
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="${demoPath}static/css/default.css" />
<%-- <script type="text/javascript" src='${demoPath}static/js/outlook2.js'> </script> --%>
<script type="text/javascript" src='${demoPath}static/js/publicmethod.js'> </script>
<style type="text/css">
.cs-navi-tab {
padding: 5px;
}
.cs-navi-tab:hover {
padding:5px;
text-decoration:none;
font-size: 16px;
color: black;
}
</style>
<script type="text/javascript">
//设置登录窗口
function openPwd() {
$('#w').window({
title: '修改密码',
width: 300,
modal: true,
shadow: true,
closed: true,
height: 160,
resizable:false
});
}
//关闭登录窗口
function closePwd() {
$('#w').window('close');
}
//修改密码
function serverLogin() {
var $newpass = $('#txtNewPass');
var $rePass = $('#txtRePass'); if ($newpass.val() == '') {
msgShow('系统提示', '请输入密码!', 'warning');
return false;
}
if ($rePass.val() == '') {
msgShow('系统提示', '请在一次输入密码!', 'warning');
return false;
} if ($newpass.val() != $rePass.val()) {
msgShow('系统提示', '两次密码不一至!请重新输入', 'warning');
return false;
} $.post('/ajax/editpassword.ashx?newpass=' + $newpass.val(), function(msg) {
msgShow('系统提示', '恭喜,密码修改成功!<br>您的新密码为:' + msg, 'info');
$newpass.val('');
$rePass.val('');
close();
}) } $(function() { openPwd(); $('#editpass').click(function() {
$('#w').window('open');
}); $('#btnEp').click(function() {
serverLogin();
}) $('#btnCancel').click(function(){closePwd();}) $('#loginOut').click(function() {
$.messager.confirm('系统提示', '您确定要退出本次登录吗?', function(r) { if (r) {
location.href = '/ajax/loginout.ashx';
}
});
})
});
</script>
</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
<noscript>
<div style=" position:absolute; z-index:100000; height:2046px;top:0px;left:0px; width:100%; background:white; text-align:center;">
<img src="${demoPath}static/image/noscript.gif" alt='抱歉,请开启脚本支持!' />
</div></noscript>
<div region="north" split="true" border="false" style="overflow: hidden; height: 30px;
background: url(${demoPath}static/image/layout-browser-hd-bg.gif) #7f99be repeat-x center 50%;
line-height: 20px;color: #fff; font-family: Verdana, 微软雅黑,黑体">
<span style="float:right; padding-right:20px;" class="head">欢迎 用户登录 <a id="editpass">修改密码</a> <a href="#" id="loginOut">安全退出</a></span>
<span style="padding-left:10px; font-size: 16px; "><img src="${demoPath}static/image/blocks.gif" width="20" height="20" align="absmiddle" />VCS后台管理</span>
</div>
<div region="south" split="true" style="height: 30px; background: #D2E0F2; ">
<div class="footer">By 天源迪科信息有限公司</div>
</div>
<div region="west" hide="true" split="true" title="导航菜单" style="width:180px;" id="west">
<div id="nav" class="easyui-accordion" fit="true" border="false">
<div title="系统管理">
<a href="javascript:void(0);" src="user/userList.html" iconCls="icon-user" class="cs-navi-tab">用户管理</a></p>
<a href="javascript:void(0);" src="role/roleList.html" class="cs-navi-tab">角色管理</a></p>
<a href="javascript:void(0);" src="permission/permissonList.html" class="cs-navi-tab">权限设置</a></p>
<a href="javascript:void(0);" src="function/functionList.html" class="cs-navi-tab">资源管理</a></p>
<a href="javascript:void(0);" src="system/log.html" class="cs-navi-tab">系统日志</a></p>
</div>
<div title="商户管理">
<a href="javascript:void(0);" src="user/userList.html" class="cs-navi-tab">商户管理</a></p>
<a href="javascript:void(0);" src="role/roleList.html" class="cs-navi-tab">商户管理</a></p>
<a href="javascript:void(0);" src="permission/permissonList.html" class="cs-navi-tab">商户管理</a></p>
<a href="javascript:void(0);" src="function/functionList.html" class="cs-navi-tab">商户管理</a></p>
<a href="javascript:void(0);" src="system/log.html" class="cs-navi-tab">商户管理</a></p>
</div>
</div>
</div>
<div id="mainPanle" region="center" style="background: #eee; overflow-y:hidden">
<div id="tabs" class="easyui-tabs" fit="true" border="false" >
<div title="欢迎使用" style="padding:20px;overflow:hidden; color:red; " >
<h1 style="font-size:24px;">* 作者:天源迪科信息有限公司</h1>
<h1 style="font-size:24px;">* BLOG: <a style="font-size:24px;color:green;" href="https://github.com/liuren">天源迪科信息有限公司</a></h1>
<h1 style="font-size:24px;">* 技术支持QQ:393993507</h1>
</div>
</div>
</div>
<!--修改密码窗口-->
<div id="w" class="easyui-window" title="修改密码" collapsible="false" minimizable="false"
maximizable="false" icon="icon-save" style="width: 300px; height: 150px; padding: 5px;
background: #fafafa;">
<div class="easyui-layout" fit="true">
<div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
<table cellpadding=3>
<tr>
<td>新密码:</td>
<td><input id="txtNewPass" type="Password" class="txt01" /></td>
</tr>
<tr>
<td>确认密码:</td>
<td><input id="txtRePass" type="Password" class="txt01" /></td>
</tr>
</table>
</div>
<div region="south" border="false" style="text-align: right; height: 30px; line-height: 30px;">
<a id="btnEp" class="easyui-linkbutton" icon="icon-ok" href="javascript:void(0)" >
确定</a> <a id="btnCancel" class="easyui-linkbutton" icon="icon-cancel" href="javascript:void(0)">取消</a>
</div>
</div>
</div> <div id="mm" class="easyui-menu" style="width:150px;">
<div id="mm-tabupdate">刷新</div>
<div class="menu-sep"></div>
<div id="mm-tabclose">关闭</div>
<div id="mm-tabcloseall">全部关闭</div>
<div id="mm-tabcloseother">除此之外全部关闭</div>
<div class="menu-sep"></div>
<div id="mm-tabcloseright">当前页右侧全部关闭</div>
<div id="mm-tabcloseleft">当前页左侧全部关闭</div>
<div class="menu-sep"></div>
<div id="mm-exit">退出</div>
</div>
</body>
</html>
userList.jsp
<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ include file="path.jsp"%>
<title>用户列表</title>
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="${demoPath}static/js/easyui/themes/icon.css">
<script type="text/javascript" src="${demoPath}static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${demoPath}static/js/easyui/jquery.easyui.min.js"></script>
</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
<table id="dg" title="用户列表" class="easyui-datagrid" style="width:1180px;height:540px;margin: 10px 5px 15px 20px;"
url="user/get_users.html"
toolbar="#toolbar" pagination="true"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th field="username" width="50">用户名</th>
<th field="password" width="50">用户密码</th>
<th field="phone" width="50">手机号</th>
<th field="email" width="50">电子邮件</th>
</tr>
</thead>
</table>
<div id="toolbar">
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加用户</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑用户</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除用户</a>
</div> <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
closed="true" buttons="#dlg-buttons">
<div class="ftitle">用户信息</div>
<form id="fm" method="post" novalidate>
<div class="fitem">
<label>用户名:</label>
<input name="username" class="easyui-textbox" required="true">
</div>
<div class="fitem">
<label>密 码:</label>
<input name="password" class="easyui-textbox" required="true">
</div>
<div class="fitem">
<label>手机号:</label>
<input name="phone" class="easyui-textbox">
</div>
<div class="fitem">
<label>电子邮箱:</label>
<input name="email" class="easyui-textbox" validType="email">
</div>
</form>
</div>
<div id="dlg-buttons">
<a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">确定</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">取消</a>
</div>
<script type="text/javascript">
var url;
function newUser(){
$('#dlg').dialog('open').dialog('setTitle','增加用户');
$('#fm').form('clear');
url = 'user/add.html';
}
function editUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$('#dlg').dialog('open').dialog('setTitle','编辑用户');
$('#fm').form('load',row);
url = 'user/edit.html?id='+row.id;
}
}
function saveUser(){
$('#fm').form('submit',{
url: url,
onSubmit: function(){
return $(this).form('validate');
},
success: function(result){
var result = eval('('+result+')');
if (result.errorMsg){
$.messager.show({
title: '保存失败!',
msg: result.errorMsg
});
} else {
$('#dlg').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the user data
}
}
});
}
function destroyUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$.messager.confirm('提示','你确定要删除用户?',function(r){
if (r){
$.post('user/del.html',{id:row.id},function(result){
if (result.success){
$('#dg').datagrid('reload'); // reload the user data
} else {
$.messager.show({ // show error message
title: '删除失败!',
msg: result.errorMsg
});
}
},'json');
}
});
}
}
</script>
<style type="text/css">
#fm{
margin:0;
padding:10px 30px;
}
.ftitle{
font-size:14px;
font-weight:bold;
padding:5px 0;
margin-bottom:10px;
border-bottom:1px solid #ccc;
}
.fitem{
margin-bottom:5px;
}
.fitem label{
display:inline-block;
width:80px;
}
.fitem input{
width:160px;
}
</style>
</body>
</html>
下面是项目的说明文件 read.md文件:
1.该项目是使用的Maven+SpringMVC+Hibernate+Mysql+easyUI+shiro
2.该项目启动器是jetty
3.run as 项目然后 输入 jetty:run 运行即可
4.用户名: admin1 admin2 admin3 admin4 密码全部是:000000
相关源代码文件存放到了百度云盘: