Wrapping request parameters using HTTPServletRequestWrapper

自闭症网瘾萝莉.ら 提交于 2019-12-04 11:07:58

I take it you are using Jersey for your REST framework?

I think this is basically saying that since the Servlet has now constructed the Request object, Jersey now cant tell the difference between form parameters and query string params.

See this for some details: https://issues.apache.org/jira/browse/STANBOL-437

This begs the question - is this actually causing you an issue or are you just worried about the warning message?

facundofarias

Right. So I've been suffering this issue, and I've been trying to solve it on different ways, but I did't want to change my web.xml settings, just because if I was testing my application with Postman it worked perfect, but when it was being integrated with the webapp it fails with the mentioned issue (A servlet request to the URI {MY_URI} contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.)

So as @clijk mentioned, you only have to set your headers as:

"Content-Type": "application/json" 
"charset": "UTF-8" 

and voilá, the warning it's gone.

Thanks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!