[英]What if main method is made parameterized, then how one can specify its real type?
[英]How can I specify method with an parameterized annotation and its value with @Pointcut
我正在用Spring MVC開發一個Web應用程序。
我想使一個方面在POST請求上執行,而不在GET請求上執行,因為我想注入阻止在HTML呈現完成之前發送的POST請求的邏輯。
@RequestMapping(value = "/aaa", method = RequestMethod.POST)
public String methodForPost(AnDto dto, Model model) {
// the aspect should be executed on this method
}
@RequestMapping(value = "/bbb", method = RequestMethod.GET)
public String methodForGET(AnDto dto, Model model) {
// the aspect shouldn't be executed on this method
}
@Pointcut
指定其值? applicationContext.xml
<aop:pointcut>
中指定帶有參數化批注的方法及其值? @Around(value="@annotation(RequestMapping)")
public Object display(ProceedingJoinPoint joinPoint, RequestMapping requestMapping ) throws Throwable {
// You have access to requestMapping. From which you can get whether its get or post and decide to proceed or not.
}
您可能需要擴展它以僅攔截包中的Requestmapping。 因為這會攔截項目中您可能擁有的每個RequestMappig,包括您可能正在使用的庫所使用的每個RequestMappig,這是一個負擔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.