码迷,mamicode.com
首页 > 编程语言 > 详细

springmvc拦截器

时间:2018-03-31 13:16:57      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:extends   技术分享   res   tar   ram   bean   map   hand   http   

1拦截器类

技术分享图片
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class DBInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest req, HttpServletResponse response, Object handler) throws Exception {
        
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
            ModelAndView modelAndView) throws Exception {
    }

    @Override
    public void afterCompletion(HttpServletRequest req, HttpServletResponse response, Object handler, Exception ex)
            throws Exception {
    }

    @Override
    public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
    }

}
View Code

2xml

技术分享图片
    <!-- com.standsoft.controller.*.* -->
    <mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/**" />
            
        <mvc:exclude-mapping path="/**/fonts/*"/>
        <mvc:exclude-mapping path="/**/*.css"/>
        <mvc:exclude-mapping path="/**/*.js"/>
        <mvc:exclude-mapping path="/**/*.png"/>
        <mvc:exclude-mapping path="/**/*.gif"/>
        <mvc:exclude-mapping path="/**/*.jpg"/>
        <mvc:exclude-mapping path="/**/*.jpeg"/>
      <!--   <mvc:exclude-mapping path="/**/*login*"/>
        <mvc:exclude-mapping path="/**/*Login*"/> -->
        <!-- 定义拦截器类 -->
            <bean class="com.standsoft.interceptor.DBInterceptor"></bean>
        </mvc:interceptor>
    </mvc:interceptors>
View Code

 技术分享图片

 

springmvc拦截器

标签:extends   技术分享   res   tar   ram   bean   map   hand   http   

原文地址:https://www.cnblogs.com/yanan7890/p/8681566.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!