sri*_*der 3 java rest post jetty
搜索了很多,但没有看到任何似乎符合我的特定情况/问题的帖子.
使用Jetty,我有一个扩展org.eclipse.jetty.server.handler.AbstractHandler的Handler类.
handle方法如下:
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
Run Code Online (Sandbox Code Playgroud)
我需要获取请求中发送的POST数据,就好像这样:
curl -H "Content-Type: application/json" -d '{"url":"http://www.example.com"}' http://localhost:8080/
基本上,我正在向我的localhost发送一个POST请求,其中一个JSON字典键入'url'.如何检索POST数据?
使用方法中HttpServletRequest参数可用的标准servlet功能Handler.handle().
将HttpServletRequest 有2种方法可以访问请求主体.
HttpServletRequest.getReader()HttpServletRequest.getInputStream()然后使用标准的java IO技术来使用其中任何一个.
| 归档时间: |
|
| 查看次数: |
5661 次 |
| 最近记录: |