我正在构建一个返回多部分响应的Web服务。我知道构建多部分响应的格式,并且如果找不到现有的工具,我将构建自己的工具。
也许我只需要帮助我的谷歌搜索技巧。我找到的所有内容都是关于POST或使用多部分消息。没有关于生成多部分响应的信息。
也许我只需要帮助我的谷歌搜索技巧。我找到的所有内容都是关于POST或使用多部分消息。没有关于生成多部分响应的信息。
import com.oreilly.servlet.MultipartResponse
//javax.servlet.http.HttpServletResponse res
MultipartResponse multi = new MultipartResponse(res);
multi.startResponse("text/plain");
out.println("On your mark");
multi.endResponse();
try { Thread.sleep(1000); } catch (InterruptedException e) { }
multi.startResponse("text/plain");
out.println("Get set");
multi.endResponse();
try { Thread.sleep(1000); } catch (InterruptedException e) { }
multi.startResponse("image/gif");
ServletUtils.returnFile(req.getRealPath("/images/go.gif"), out);
multi.finish();
http://hc.apache.org/httpclient-3.x/methods/multipartpost.html