当前位置:网站首页>通过实现参数解析器HandlerMethodArgumentResolver接口来自定义注解
通过实现参数解析器HandlerMethodArgumentResolver接口来自定义注解
2022-04-23 07:16:00 【hungry&foolish】
HandlerMethodArgumentResolver类似于拦截器,是一个参数解析器,我们可以通过写一个类实现HandlerMethodArgumentResolver接口来实现对Controller层中方法参数的修改
自定义解析器需要实现HandlerMethodArgumentResolver接口,HandlerMethodArgumentResolver接口包含两个接口函数:

当supportsParameter返回True时,才会调用resolveArgument。
实例:
声明自定义的注解(用于获取用户的userid)

写一个LoginUserHandlerMethodArgumentResolver类实现HandlerMethodArgumentResolver接口

在resolveArgument中会获取token,然后根据token获取userid并返回
版权声明
本文为[hungry&foolish]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_35227352/article/details/124302257
边栏推荐
- LeetCode简单题之计算字符串的数字和
- Principle of sentinel integrating Nacos to update data dynamically
- [programming practice / embedded competition] learning record of embedded competition (II): picture streaming based on TCP
- Anti shake and throttling
- 在MATLAB中快速画圆(给出圆心坐标和半径就能直接画的那种)
- Penetration test interview collection -- HVV---
- Thinkphp6 + JWT realizes login verification
- 編譯原理題-帶答案
- 简述CPU
- 浏览器中的 Kubernetes 和 IDE | 交互式学习平台Killercoda
猜你喜欢

The third divisor of leetcode simple question

The simple problem of leetcode is to calculate the numerical sum of strings

PyQt5开发之QTableWidget表头自定义与美化(附源代码下载)

简述CPU

Qt编译QtXlsx库

Smart business card applet business card details page function implementation key code

Why are there 1px problems? How?

岛屿的个数

LeetCode简单题之计算字符串的数字和

青苹果影视系统源码 影视聚合 影视导航 影视点播网站源码
随机推荐
LeetCoed18. 四数之和
Codeforces Round #784 (Div. 4)
PHP high precision computing
LeetCode简单题之统计字符串中的元音子字符串
3C装配中的机械臂运动规划
英语课小记(四)
【Appium】测试时遇到手机内嵌H5页面的切换问题
网赚APP资源下载类网站源码
搜一下导航完整程序源码
CGM优化血糖监测管理——移宇科技亮相四川省国际医学交流促进会
dried food! Point based: differentiable Poisson solver
Briefly describe the hierarchical strategy of memory
Qt编译QtXlsx库
[Effective Go 中文翻译] 第一篇
sql 使用过的查询语句
Face to face summary 2
高精度焊接机械臂定位
三星,再次“西征”
Interesting JS code
Quick rehearsal exercise