当前位置:网站首页>通过实现参数解析器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
边栏推荐
- 【解释】get ORA-12838: cannot read/modify an object after modifying it in parallel
- AAAI 2022招募讲者啦!!
- nn.Module类的讲解
- Canvas learning Chapter 1
- 干货!以点为形:可微分的泊松求解器
- [programming practice / embedded competition] learning record of embedded competition (II): picture streaming based on TCP
- dmp引擎工作总结(2021,光剑)
- 3C装配中的机械臂运动规划
- 渗透测试面试合集---HVV---
- 常用正则表达式
猜你喜欢
[programming practice / embedded competition] learning record of embedded competition (II): picture streaming based on TCP
Canvas learning Chapter 1
扎心了!一女子发朋友圈羡慕别人按时发工资被开除,连点赞的同事也一同被开除了...
Data security has become a hidden danger. Let's see how vivo can make "user data" armor again
Discussion on ES6 tail tune optimization
巨头押注的全屋智能,正在驱动海信、华为、小米们「自我革命」
智能名片小程序名片详情页功能实现关键代码
thinkphp6+jwt 实现登录验证
Qt利用QtXlsx操作excel文件
简述CPU
随机推荐
高精度焊接机械臂定位
Why are there 1px problems? How?
Samsung, March to the west again
Principle of sentinel integrating Nacos to update data dynamically
Quick rehearsal exercise
编译原理题-带答案
The following program deletes n consecutive words starting from the ith character from the string str
Rearranging log files for leetcode simple question
Discussion on ES6 tail tune optimization
Codeforces Round #784 (Div. 4)
三星,再次“西征”
mysql查询字符串类型的字段使用数字类型查询时问题
Data security has become a hidden danger. Let's see how vivo can make "user data" armor again
LeetCode簡單題之計算字符串的數字和
Rotation function of leetcode medium problem
以下程序实现从字符串str中删除第i个字符开始的连续n个字
【无标题】
Implementation principle of instanceof
Comparison of indoor positioning methods of several intelligent robots
Draw a circle quickly in MATLAB (the one that can be drawn directly given the coordinates and radius of the center of the circle)