新建Java Daynamic Web项目

导入Spring、SpringMVC依赖包:

导入Spring & Spring MVC包(导入如下所有开发包):

Java-Shiro(三):Shiro与Spring MVC集成

Spring AOP依赖扩展包:

Java-Shiro(三):Shiro与Spring MVC集成

配置Spring : 

1)修改web.xml导入“#contextLoaderListener”

Java-Shiro(三):Shiro与Spring MVC集成

配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <display-name>shiro-web-01</display-name>
    <!-- 配置Spring的 ContextLoaderListener -->
    <!-- needed for ContextLoaderListener -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>

    <!-- Bootstraps the root web application context before servlet initialization -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>
View Code

相关文章: