入參格式為JSON而非普通字符串,形如: { "REQUEST": { "page": "1", "rows":"20"
}
}在普通Controller中通過@RequestBody String REQUEST即可解析該JSON入參,但在自定義的切面類 RequestInterceptor 中如何獲取這樣的入參呢?因為入參為JSON字符串,無法通過request.getParameter()獲取@Aspect@Componentpublic class RequestInterceptor {
@Autowired
private HttpServletRequest request;
@Pointcut("execution(* com.api.controller..*.*(..))")
public void point() {
} @Before(value = "point()")
public void doBefore(JoinPoint joinPoint) throws Throwable { // 獲取入參進行初始化
}
}
SpringBoot:如何使用AOP攔截參數類型為JSON的請求
婷婷同學_
2018-10-24 20:42:18