本文最后更新于 2892 天前,其中的信息可能已经有所发展或是发生改变。
前言
这个是学习shiro过程中一个demo产物…
也为了自己毕业设计权限那块而学习的…
学习计划也完成了shiro..
接下来应该到memcache和radis的缓存技术了…
emmm代码明天才发吧…
密码是明文创建的..这次没有使用shiro内置的加密..
一步一步完善吧…学习为主的一个框架..
效果图:



数据库
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for t_human
-- ----------------------------
DROP TABLE IF EXISTS `t_human`;
CREATE TABLE `t_human` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) DEFAULT NULL,
`age` int(3) DEFAULT NULL,
`sex` int(2) DEFAULT NULL,
`remark` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_human
-- ----------------------------
INSERT INTO `t_human` VALUES ('17', '阿达', '2', '2', '1223123');
INSERT INTO `t_human` VALUES ('18', '阿达', '2', '2', '1223123');
INSERT INTO `t_human` VALUES ('19', '阿达', '2', '2', '1223123');
-- ----------------------------
-- Table structure for t_permission
-- ----------------------------
DROP TABLE IF EXISTS `t_permission`;
CREATE TABLE `t_permission` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`permissionName` varchar(50) DEFAULT NULL,
`roleId` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `roleId` (`roleId`),
CONSTRAINT `t_permission_ibfk_1` FOREIGN KEY (`roleId`) REFERENCES `t_role` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_permission
-- ----------------------------
INSERT INTO `t_permission` VALUES ('1', 'admin:*', '1');
INSERT INTO `t_permission` VALUES ('2', 'user:update:*', '2');
INSERT INTO `t_permission` VALUES ('3', 'user:update:*', '1');
-- ----------------------------
-- Table structure for t_role
-- ----------------------------
DROP TABLE IF EXISTS `t_role`;
CREATE TABLE `t_role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`roleName` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_role
-- ----------------------------
INSERT INTO `t_role` VALUES ('1', 'admin');
INSERT INTO `t_role` VALUES ('2', 'user');
-- ----------------------------
-- Table structure for t_user
-- ----------------------------
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userName` varchar(20) DEFAULT NULL,
`password` varchar(100) DEFAULT NULL,
`roleId` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `roleId` (`roleId`),
CONSTRAINT `t_user_ibfk_1` FOREIGN KEY (`roleId`) REFERENCES `t_role` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_user
-- ----------------------------
INSERT INTO `t_user` VALUES ('6', 'admin', 'admin', '1');
INSERT INTO `t_user` VALUES ('7', 'user', 'user', '2');
代码在github:https://github.com/jiomer/shiro_demo
晚安

共勉,同刚毕业,感觉跟博主差距好大,继续学习了
导入不了github,可以分享么,作为初学者,这个是很全面的demo
我已经很久没看了~忘记了~
没事,我已经弃用shiro改用security了