设为首页 加入收藏

TOP

Spring MVC中登录过滤器使用(二)
2018-08-16 09:31:26 】 浏览:208
Tags:Spring MVC 登录 过滤器 使用
p;       if (uri.indexOf(string) > -1)
            {
                return true;
            }
        }
       
        return false;
    }
   
}


上面提到的对静态资源不过滤,当然springmvc中也要设置静态资源的请求不经过DispatcherServlet,此时就需要在spring-mvc.xml中进行设置,小编基本使用默认的配置,如下代码中的<mvc:default-servlet-handler />


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.3.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd ">
       
    <context:component-scan base-package="com.yongcheng.liuyang.controller">
    </context:component-scan>
    <context:component-scan base-package="com.yongcheng.liuyang.listener" />
       
<!--    spring MVC不处理静态资源  -->
    <mvc:default-servlet-handler />   
<!--    支持MVC的注解驱动 -->
    <mvc:annotation-driven />
   
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
        id="internalResourceViewResolver" >
<!--        自动添加到路径中的前缀 -->
        <property name="prefix" value="/jsp/" />
<!--        自动添加到路径中的后缀 -->
        <property name="suffix" value=".jsp" />
    </bean>
   
</beans>


好了,以上就是springmvc中简答的filter使用!如有任何疑问,欢迎留言交流!!


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇mybatis的sqlSessionFactory的加.. 下一篇深入理解Java内存与垃圾回收调优

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目