HttpServletRequest获取请求体数据,

//java8 可用
String body = request.getReader().lines().collect(Collectors.joining());
request.getReader().lines()得到一个stream流
.collect(Collectors.joining())相当于是拼接字符串

例:List list = Arrays.asList("1","2","3");
String s =  list.stream.collect(Collectors.joining(","))

打印:s = 1,2,3



 

posted @ 2023-02-22 16:22  xxfcode  阅读(197)  评论(0编辑  收藏  举报