我希望编写自定义注释,根据注释修改Spring请求或路径参数。例如,代替这段代码:
@RequestMapping(method = RequestMethod.GET)
public String test(@RequestParam("title") String text) {
text = text.toUpperCase();
System.out.println(text);
return "form";
}
我可以进行注释 @UpperCase :
@RequestMapping(method = RequestMethod.GET)
public String test(@RequestParam("title") @UpperCase String text) {
System.out.println(text);
return "form";
}
这是否可能,如果是的话,我该如何做到?
HandlerMethodArgumentResolver
接口。 - Sotirios Delimanolis@Before("@annotation(my.pkg.annotation.UpperCase)")
的方法,然后在该方法中转换参数。 - beerbajay