1.首先要导入相应的依赖库
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-spring --> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.4.1</version> </dependency>
2.导入依赖库之后,就需要配置web.xml文件
<filter> <filter-name>shiroFilter</filter-name><!--这里的"shiroFilter"名称必须要与Spring配置文件的名称保持一致,例如:如果要定义一个spring-shiro.xml配置文件的话,就需要为其追加同样的shiroFilter配置项-->
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
<init-param>
<param-name>
targetFilterLifecycle
</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3.