java注解修改值
我有一个带有 spring 的 Web 应用程序,一个休息端点接收一个像这样加密的值:
@RequestMapping(value = "/welcome", method = RequestMethod.GET)
public resp welcome(
@RequestHeader(name = "user") String user,
@Encripted @RequestHeader(name = "password") String password
我正在创建这样的注释 @Encripted:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface Encripted {
}
现在我需要操作已注释的字符串并更改其值,我如何覆盖或实现为了实现这个目标?我找不到 ElementType.PARAMETER 的示例,
I have a web application with spring, one rest endpoint receives a value encrypted like this:
@RequestMapping(value = "/welcome", method = RequestMethod.GET)
public resp welcome(
@RequestHeader(name = "user") String user,
@Encripted @RequestHeader(name = "password") String password
I'm creating the annotation @Encripted like this:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface Encripted {
}
now I need to manipulate the String that got annotated and change its value, how could I override or implement to achieve this goal? I can't find example with ElementType.PARAMETER,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您在
com.example.controller
中创建了WelcomeController
和Encrypted
类,为了处理注释,您需要创建一个方面像这样的类 --
在此处查看有关 Spring 的 AOP 的更多信息 -- https://www.baeldung.com/spring-aop
Lets say you created
WelcomeController
andEncrypted
classes incom.example.controller
like so,In order to process the Annotation you need to create an Aspect class like so --
Check more on the AOP with Spring here -- https://www.baeldung.com/spring-aop