资源简介
shiro登录验证实例,下载包虽然是web_exception_project.zip,但是确实是shiro登录验证实例,请放心下载,另外,实例详情请访问博主博客:http://blog.csdn.net/u013142781
代码片段和文件信息
package com.luo.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.druid.support.json.JSONUtils;
import com.luo.errorcode.LuoErrorCode;
import com.luo.exception.BusinessException;
import com.luo.util.DecriptUtil;
@Controller
public class UserController {
@RequestMapping(“/index.jhtml“)
public ModelAndView getIndex(HttpServletRequest request) throws Exception {
ModelAndView mav = new ModelAndView(“index“);
return mav;
}
@RequestMapping(“/exceptionForPageJumps.jhtml“)
public ModelAndView exceptionForPageJumps(HttpServletRequest request) throws Exception {
throw new BusinessException(LuoErrorCode.NULL_OBJ);
}
@RequestMapping(value=“/businessException.json“ method=RequestMethod.POST)
@ResponseBody
public String businessException(HttpServletRequest request) {
throw new BusinessException(LuoErrorCode.NULL_OBJ);
}
@RequestMapping(value=“/otherException.json“ method=RequestMethod.POST)
@ResponseBody
public String otherException(HttpServletRequest request) throws Exception {
throw new Exception();
}
//跳转到登录页面
@RequestMapping(“/login.jhtml“)
public ModelAndView login() throws Exception {
ModelAndView mav = new ModelAndView(“login“);
return mav;
}
//跳转到登录成功页面
@RequestMapping(“/loginsuccess.jhtml“)
public ModelAndView loginsuccess() throws Exception {
ModelAndView mav = new ModelAndView(“loginsuccess“);
return mav;
}
@RequestMapping(“/newPage.jhtml“)
public ModelAndView newPage() throws Exception {
ModelAndView mav = new ModelAndView(“newPage“);
return mav;
}
@RequestMapping(“/newPageNotAdd.jhtml“)
public ModelAndView newPageNotAdd() throws Exception {
ModelAndView mav = new ModelAndView(“newPageNotAdd“);
return mav;
}
/**
* 验证用户名和密码
* @param String usernameString password
* @return
*/
@RequestMapping(value=“/checkLogin.json“method=RequestMethod.POST)
@ResponseBody
public String checkLogin(String usernameString password) {
Mapject> result = new HashMapject>();
try{
UsernamePasswordToken token = new UsernamePasswordToken(username DecriptUtil.MD5(password));
Subject currentUser = SecurityUtils.getSubject();
if (!currentUser.isAuthenticated()){
//使用shiro来验证
token.setRememberMe(true);
currentUser.login(token);//验证角色和权限
}
}catch( 属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-02-01 08:55 web_exception_project\
文件 1686 2016-01-30 18:11 web_exception_project\.classpath
文件 1230 2016-01-30 18:10 web_exception_project\.project
目录 0 2016-02-01 08:55 web_exception_project\.settings\
文件 575 2016-01-30 18:10 web_exception_project\.settings\.jsdtscope
文件 430 2016-01-30 18:11 web_exception_project\.settings\org.eclipse.jdt.core.prefs
文件 90 2016-01-30 18:10 web_exception_project\.settings\org.eclipse.m2e.core.prefs
文件 793 2016-01-30 18:11 web_exception_project\.settings\org.eclipse.wst.common.component
文件 252 2016-01-30 18:11 web_exception_project\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2016-01-30 18:10 web_exception_project\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2016-01-30 18:10 web_exception_project\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 50 2016-01-30 18:10 web_exception_project\.settings\org.eclipse.wst.validation.prefs
文件 3624 2016-02-02 19:47 web_exception_project\pom.xm
目录 0 2016-02-01 08:55 web_exception_project\src\
目录 0 2016-02-01 08:55 web_exception_project\src\main\
目录 0 2016-02-02 20:01 web_exception_project\src\main\java\
目录 0 2016-02-01 08:55 web_exception_project\src\main\java\com\
目录 0 2016-02-02 21:12 web_exception_project\src\main\java\com\luo\
目录 0 2016-02-01 08:55 web_exception_project\src\main\java\com\luo\controller\
文件 3663 2016-02-03 12:59 web_exception_project\src\main\java\com\luo\controller\UserController.java
目录 0 2016-02-01 08:55 web_exception_project\src\main\java\com\luo\errorcode\
文件 843 2016-02-03 12:59 web_exception_project\src\main\java\com\luo\errorcode\LuoErrorCode.java
目录 0 2016-02-01 08:55 web_exception_project\src\main\java\com\luo\exception\
文件 222 2016-01-29 21:51 web_exception_project\src\main\java\com\luo\exception\BusinessException.java
目录 0 2016-02-01 17:33 web_exception_project\src\main\java\com\luo\exceptionresolver\
文件 2162 2016-02-03 12:56 web_exception_project\src\main\java\com\luo\exceptionresolver\MySimpleMappingExceptionResolver.java
目录 0 2016-02-02 20:01 web_exception_project\src\main\java\com\luo\shiro\
目录 0 2016-02-02 20:02 web_exception_project\src\main\java\com\luo\shiro\realm\
文件 1791 2016-02-03 12:57 web_exception_project\src\main\java\com\luo\shiro\realm\MyShiroRealm.java
目录 0 2016-02-02 21:12 web_exception_project\src\main\java\com\luo\util\
文件 6425 2016-02-03 08:56 web_exception_project\src\main\java\com\luo\util\DecriptUtil.java
............此处省略196个文件信息
- 上一篇:KRF-35开发包
- 下一篇:深入理解计算机系统 lab
相关资源
- SSM+Shiro+redis实现单点登陆
- 跟我学shiro pdf带目录版
- 2018年SpringBoot与Shiro整合-权限管理实战
- jfinalShiroEasyui
- ssm+shiro+easyui权限管理系统
- springboot+springdatajpa+thymeleaf+shiro 的管理
- Apache Shiro技术详解
- springboot+shiro+md5
- shiro 中文 API文档
- springboot+Shiro 实现动态授权
- spring boot+mybatis+thymeleaf+apache shiro开发
- 跟我学Shiro PDF版教程与源码. 张开涛
- Springboot+shiro简单登录案例
- spring boot+mybatis+thymeleaf+apache shiro开发
- Spring+SpringMVC+Mybatis+AdminLTE(BootStrap)
- shiro官方文档中文
- springboot + shiro + mybatis-plus + beetl后台管
- 跟我学Shiro教程.rar
- shiro反序列化复现.zip
- springMVC+hibernate+spring+shiro整合
- Shiro学习,以及与SpringMVC整合,标签注
- ssm整合shrio框架
- 高仿小米商城对应的后台管理系统
- BNF-寇申海.rar
- springboot+mybatis+layui+shiro 权限注解-后台
- springboot+mybatis+shiro+rabbitmq+redis项目实
- 高仿京淘项目
- ssm+shiro+redis 登录控制及重试次数超过
- Shiro和AJAX完美整合
- SpringMVC + Shiro 权限控制
川公网安备 51152502000135号
评论
共有 条评论