入参格式为JSON而非普通字符串,形如:
{
"REQUEST": {
"page": "1",
"rows":"20"
}
}
在普通Controller中通过@RequestBody String REQUEST即可解析该JSON入参,但在自定义的切面类 RequestInterceptor 中如何获取这样的入参呢?因为入参为JSON字符串,无法通过request.getParameter()获取
@Aspect
@Component
public class RequestInterceptor {
@Autowired
private HttpServletRequest request;
@Pointcut("execution(* com.api.controller..*.*(..))")
public void point() {
}
@Before(value = "point()")
public void doBefore(JoinPoint joinPoint) throws Throwable {
// 获取入参进行初始化
}
}
似乎找到了可行的解决办法:
https://stackoverflow.com/que...