首页 > 代码库 > spring拦截器
spring拦截器
<!-- 将拦截所有请求 --> <!-- <mvc:interceptors> --> <!-- <bean class="com.SpringInter"></bean> --> <!-- </mvc:interceptors> --> <!-- 针对具体路径进行拦截 --> <mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/test"/> <bean class="com.SpringInter"></bean> </mvc:interceptor> </mvc:interceptors>
package com; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.ModelAndView; public class SpringInter implements HandlerInterceptor { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String url=request.getRequestURI(); System.out.println(url); return true; } public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { } public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { } }
spring拦截器
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。