当前位置:网站首页>MVC自定义配置
MVC自定义配置
2022-08-04 05:31:00 【Louzen】
学习资料
MVC自定义配置
实现WebMvcConfigurer接口,并重写相关方法
自定义拦截器(登录拦截为例)
// 1、先定义一个拦截器,实现HandlerInterceptor接口并实现里面的三个方法
public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
return Objects.nonNull(request.getAttribute("loginUser"));
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
}
}
// 2、实现WebMvcConfigurer接口对web进行自定义配置,重写addInterceptors方法添加自定义拦截器
@Configuration
public class AdminWebConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new LoginInterceptor())
.addPathPatterns("/**")
.excludePathPatterns("/", "/login");
}
}
边栏推荐
- Deep Learning Theory - Initialization, Parameter Adjustment
- MNIST Handwritten Digit Recognition - Image Analysis Method for Binary Classification
- 卷积神经网络入门详解
- Pytest常用插件
- [开发杂项][VS Code]remote-ssd retry failed
- PCL1.12 解决memory.h中EIGEN处中断问题
- 光条中心提取方法总结(二)
- LeetCode_Nov_4th_Week
- 彻底删除MySQL教程
- MNIST Handwritten Digit Recognition - From Perceptrons to Convolutional Neural Networks
猜你喜欢

YOLOV5 V6.1 详细训练方法

MNIST Handwritten Digit Recognition - Image Analysis Method for Binary Classification
![[Copy Siege Lion Log] Flying Pulp Academy Intensive Learning 7-Day Punch Camp-Study Notes](/img/af/05caea638de8d75f6d3b42b3d8e28f.png)
[Copy Siege Lion Log] Flying Pulp Academy Intensive Learning 7-Day Punch Camp-Study Notes

MNIST handwritten digit recognition, sorted by from two to ten

基于BiGRU和GAN的数据生成方法

深度学习理论 —— 初始化、参数调节

arm-3-中断体系结构

代码庆端午--粽你心意

题目1000:输入两个整数a和b,计算a+b的和,此题是多组测试数据

MNIST手写数字识别 —— ResNet-经典卷积神经网络
随机推荐
2020-10-29
Golang环境变量设置(二)--GOMODULE&GOPROXY
LeetCode_Dec_3rd_Week
Cut the hit pro subtitles export of essays
安装MySQL的详细步骤
[开发杂项][调试]debug into kernel
LeetCode_22_Apr_4th_Week
Rules.make-适合在编辑模式下看
【代码学习】
How to get started with MOOSE platform - an example of how to run the official tutorial
图像合并水平拼接
A code example of the PCL method in the domain of DG (Domain Generalization)
Copy攻城狮的年度之“战”|回顾2020
中国联通、欧莱雅和钉钉都在争相打造的秘密武器?虚拟IP未来还有怎样的可能
tensorRT教程——使用tensorRT OP 搭建自己的网络
[Copy Siege Lion Log] Flying Pulp Academy Intensive Learning 7-Day Punch Camp-Study Notes
CAS无锁队列的实现
代码庆端午--粽你心意
审稿意见回复
How to grow into a senior engineer?