从Java servlet中的POST请求获取请求有效负载

问题描述:

我有一个javascript库正在向我的Java servlet发送POST请求,但是在 doPost 方法中,我似乎无法获取请求的内容有效载荷。在chrome Developer Tools中,所有内容都在headers选项卡的Request Payload部分中,内容就在那里,我知道doPost方法正在接收POST,但它只是空白。

I have a javascript library that is sending a POST request to my Java servlet, but in the doPost method, I can't seem to get the contents of the request payload. In chrome Developer Tools, all the content is in the Request Payload section in the headers tab, and the content is there, and I know that the POST is being received by the doPost method, but it just comes up blank.

对于 HttpServletRequest
对象,我可以通过何种方式获取请求有效负载中的数据?

For the HttpServletRequest object, what way can I get the data in the request payload?

执行 request.getParameter() request.getAttributes()
最终都没有数据

Doing request.getParameter() or request.getAttributes() both end up with no data

使用 getReader()阅读请求的正文