Apache Shiro(五)-登录认证和权限管理ssm

 2023-02-25    336  

创建一个web动态项目

  Apache Shiro(五)-登录认证和权限管理ssm

jar包

  Apache Shiro(五)-登录认证和权限管理ssm

web.xml

web.xml做了如下几件事情
1. 指定spring的配置文件有两个

1 applicationContext.xml: 用于链接数据库的
2 applicationContext-shiro.xml: 用于配置shiro的

2. 指定springmvc的配置文件

1 springMVC.xml

3. 使用shiro过滤器

1 <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3          xmlns="http://java.sun.com/xml/ns/javaee"
 4          xmlns:web="http://java.sun.com/xml/ns/javaee"
 5          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
 6      
 7     <!-- spring的配置文件-->
 8     <context-param>
 9         <param-name>contextConfigLocation</param-name>
10         <param-value>
11             classpath:applicationContext.xml,
12             classpath:applicationContext-shiro.xml
13         </param-value>
14     </context-param>
15     <listener>
16         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
17     </listener>
18      
19     <!-- spring mvc核心:分发servlet -->
20     <servlet>
21         <servlet-name>mvc-dispatcher</servlet-name>
22         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
23         <!-- spring mvc的配置文件 -->
24         <init-param>
25             <param-name>contextConfigLocation</param-name>
26             <param-value>classpath:springMVC.xml</param-value>
27         </init-param>
28         <load-on-startup>1</load-on-startup>
29     </servlet>
30     <servlet-mapping>
31         <servlet-name>mvc-dispatcher</servlet-name>
32         <url-pattern>/</url-pattern>
33     </servlet-mapping>
34      
35     <!-- Shiro配置 -->
36     <filter>
37         <filter-name>shiroFilter</filter-name>
38         <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
39         <init-param>
40             <param-name>targetFilterLifecycle</param-name>
41             <param-value>true</param-value>
42         </init-param>
43     </filter>
44     <filter-mapping>
45         <filter-name>shiroFilter</filter-name>
46         <url-pattern>/*</url-pattern>
47     </filter-mapping>
48      
49 </web-app>

点击展开

以上所述是小编给大家介绍的Apache Shiro(五)-登录认证和权限管理ssm,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!

原文链接:https://77isp.com/post/34309.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。