SpringBoot拦截器的使用
来源:互联网 发布:购买的域名如何使用 编辑:程序博客网 时间:2024/05/21 13:58
1:启动类
package com.rs.domain;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.config.annotation.InterceptorRegistry;import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;import com.rs.incident.controller.IncidentAddInterceptor;@Configuration@ComponentScan("com.rs")@EnableAutoConfigurationpublic class SysConfiguration { public static void main(String[] args) { SpringApplication.run(SysConfiguration.class, args); } @Configuration static class WebConfig extends WebMvcConfigurerAdapter { @Autowired IncidentAddInterceptor incidentAddInterceptor; /** * 配置拦截器 * * @author lance * @param registry */ @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(incidentAddInterceptor).addPathPatterns("/incident/add"); } }}
2:定义拦截器
package com.rs.incident.controller;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.stereotype.Component;import org.springframework.web.servlet.HandlerInterceptor;import org.springframework.web.servlet.ModelAndView;import com.rs.log.service.LogService;import com.rs.util.handler.InterceptorHelp;@Componentpublic class IncidentAddInterceptor implements HandlerInterceptor { @Resource(name = "logService") private LogService logService; @Override public boolean preHandle(HttpServletRequest request, 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 request, HttpServletResponse response, Object handler, Exception ex) throws Exception { }}
0 0
- SpringBoot拦截器的使用
- SpringBoot拦截器的使用
- springboot使用拦截器
- 使用springBoot的拦截器功能介绍
- springboot 中拦截器的使用
- 在SpringBoot中使用 拦截器
- springboot 配置使用拦截器 interceptor
- 在SpringBoot中使用 拦截器
- SpringBoot学习笔记之拦截器使用
- springboot的监听器,拦截器与过滤器
- springboot 拦截器配置
- SpringBoot--实现拦截器
- springboot添加拦截器
- springboot添加拦截器
- SpringBoot拦截器
- SpringBoot 自定义拦截器
- SpringBoot-拦截器
- SpringBoot之拦截器
- ios 10 开发-使用 Extension(Intents Extension和Intents UI Extens)创建SiriKit功能开发
- 安卓开发复习笔记——Fragment+FragmentTabHost组件(实现新浪微
- 分享下多年积累的对JAVA程序员成长之路的总结 --本文内容转自JAVA吧
- mysql 练习题
- spring ioc设计之BeanFactory接口系统解析
- SpringBoot拦截器的使用
- linux进程间通信之消息队列
- Android实践 -- 监听应用程序的安装、卸载
- 常见的join算法
- catmaid主分支笔记
- 什么是自适应学习(个性化学习)?
- 量化投资--量化干货分享
- SQLite3数据库在嵌入式应用之三: 以日志功能为例给出常用命令和C/C++常用API
- redis 删除 模糊匹配字段