【发布时间】:2022-11-12 01:58:42
【问题描述】:
我的问题是这个。
我想为spring boot添加自定义注释并将其指定为已声明而不声明特定逻辑。
假设您有以下代码:
@MyCustomAnnotation
@Controller
public class ExController {
@RequestMapping(value = "/index", method = RequestMethod.GET)
public String index(Model model){
return "index";
}
}
我希望上面的代码执行以下逻辑。
@MyCustomAnnotation
@Controller
public class ExController {
@RequestMapping(value = "/index", method = RequestMethod.GET)
public String index(Model model){
//Code added because it has an annotation
model.addAttribute("key","value");
//Code added because it has an annotation
return "index";
}
}
一直在想Reflection等方法,但是想不出正确的方法
有人可以为这个问题提供解决方案或关键字吗?
【问题讨论】:
标签: java spring-boot annotations inversion-of-control spring-annotations