功能描述:
Authentication:身份认证/登录,验证用户是不是具有相应的身份。
Authorization:授权,即权限验证,验证某个已认证的用户是否具有某个权限,即判断用户能否进行某个操作。
Session Management:会话管理,即用户登录后就是一次会话,在没有退出之前,它的所有信息都在这个会话中。
Cryptography:加密,保护数据的安全性,如密码加密存储到数据库。
Web Support:web项目集成,非常容易集成到Web项目中。
Caching:缓存。比如用户登录后,其用户信息和权限都保存到缓存中,提高效率。
Concurrency:多线程的授权验证。支持在多线程之间进行并发验证。
Tesing:提供测试支持。
Run As:允许一个用户以另外一种身份来操作项目(对方允许的情况)。
Remember Me:记住我。即一次登录后,下次再来就不需要再重新登录了。
1.导包
2.配置web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>Shiro</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!-- spring配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- SpringMVC的配置文件 -->
<servlet>
<servlet-name>springDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springDispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- 添加shiro过滤器,用来拦截shiro请求 -->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>
org.springframework.web.filter.Delega