67,550
社区成员




@RestController
@RequestMapping("/test")
public class BoardController {
@RequestMapping(value = "/board", method = {RequestMethod.POST})
public ApiResult board(@RequestBody Map<String, Object> params) throws Exception {
return ApiResult.succ(null);
}
}
// 获取成员方法的class对象
Method board = BoardController.class.getMethod("board", Map.class);
// 获取 Test 上的注解
RequestMapping requestMapping = board.getAnnotation(RequestMapping.class);
// 获取代理处理器
InvocationHandler handler = Proxy.getInvocationHandler(requestMapping);
// 过去私有 memberValues 属性
Field f = handler.getClass().getDeclaredField("memberValues");
f.setAccessible(true);
// 获取实例的属性map
Map<String, Object> memberValues = (Map<String, Object>) f.get(handler);
// 修改属性值
memberValues.put("value", "/url");