您可以使用oreilly servlets http://www.servlets.com/cos/
一个例子是在javadoc:http://www.servlets.com/cos/javadoc/com/oreilly/servlet/MultipartResponse.html
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();
Run Code Online (Sandbox Code Playgroud)
小智 -1
您尝试过 Apache HttpClient 项目吗?自从它从 Apache Commons 中爆发出来以来,我就没有看过它,但我知道它在多部分响应方面做了很多工作。
这是为了消费——不确定是否有任何东西可以生产,但这可能是一个开始的地方。
http://hc.apache.org/httpclient-3.x/methods/multipartpost.html