• spring+springMVC+mybatis+shiro -- web.xml


    <?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_3_0.xsd"
        id="WebApp_ID" version="3.0">
    
        <!-- spring硬编码 -->
        <filter>
            <filter-name>characterEncodingFilter</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>UTF-8</param-value>
            </init-param>
            <init-param>
                <param-name>forceEncoding</param-name>
                <param-value>true</param-value>
            </init-param>
        </filter>
        <filter-mapping>
            <filter-name>characterEncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
        <!-- spring监听器 -->
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring-config.xml</param-value>
        </context-param>
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    
        <!-- springMVC前端控制器 -->
        <servlet>
            <servlet-name>DispatcherServlet</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath:applicationContext/spring-mvc.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>DispatcherServlet</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
    
        <!-- shiro -->
        <filter>
            <filter-name>shiroFilter</filter-name>
            <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>
    
        <welcome-file-list>
            <welcome-file>/WEB-INF/welcome.jsp</welcome-file>
        </welcome-file-list>
        <error-page>
            <error-code>404</error-code>
            <location>/WEB-INF/view/error/404.jsp</location>
        </error-page>
        <error-page>
            <error-code>500</error-code>
            <location>/WEB-INF/view/error/500.jsp</location>
        </error-page>
    
    </web-app>

      在网上看到好多都说springMVC必须在 shiroFilter前面,经测试,和位置没有关系,或者本人没有测试出应该有的功能,请大神指教。

  • 相关阅读:
    IT战略规划项目方法论(转)
    008_Node中的require和import
    007_Mac上安装Node和NPM
    005_讨论多线程和单线程
    006_饿了么大前端总监sofish帮你理清前端工程师及大前端团队的成长问题!
    005_解密饿了么大前端团队
    005_python对整数的拼接
    010_动态语言与鸭子类型及python2和3的区别
    010_vim和python整合开发
    009_一行python重要工具
  • 原文地址:https://www.cnblogs.com/foreign-student/p/7593944.html
Copyright © 2020-2023  润新知