入?yún)⒏袷綖镴SON而非普通字符串,形如: { "REQUEST": { "page": "1", "rows":"20"
}
}在普通Controller中通過@RequestBody String REQUEST即可解析該JSON入?yún)?,但在自定義的切面類 RequestInterceptor 中如何獲取這樣的入?yún)⒛??因為入?yún)镴SON字符串,無法通過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 { // 獲取入?yún)⑦M行初始化
}
}
SpringBoot:如何使用AOP攔截參數(shù)類型為JSON的請求
婷婷同學(xué)_
2018-10-24 20:42:18