springcloud中假如后端服务有@RequestMapping("/test")
pubilc void test(@RequestBody MyPram myParam){
...
}在zuul网关的过滤器中,我要获取myParam的值, RequestContext ctx = RequestContext.getCurrentContext(); HttpServletRequest request = ctx.getRequest();然后如何通过Request获取myParam的值?
2 回答

慕田峪7331174
TA贡献1828条经验 获得超13个赞
String body = request.getReader().lines().collect(Collectors.joining(System.lineSeparator())); MyParam myParam = JSON.parseObject(body,MyParam.class);
添加回答
举报
0/150
提交
取消