当前位置: 技术问答>java相关
请教高手:在request对象中取得multipart/form-data格式的二进制数据是不是用request.getInputStream呀?
来源: 互联网 发布时间:2014-12-28
本文导语: 问题是:我该用什么类型的变量接受它?byte[]说不对,String也说不对...... 请教大侠! | 啊,写错啦。 byte[] ggg = new byte[1024]; abc.readLine(ggg, 0, ggg.length); | 建议你看一下这个极其简单的例子...
问题是:我该用什么类型的变量接受它?byte[]说不对,String也说不对......
请教大侠!
请教大侠!
|
啊,写错啦。
byte[] ggg = new byte[1024];
abc.readLine(ggg, 0, ggg.length);
byte[] ggg = new byte[1024];
abc.readLine(ggg, 0, ggg.length);
|
建议你看一下这个极其简单的例子:
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = new PrintWriter (response.getOutputStream());
out.println("");
out.println("ShowFormdata");
out.println("");
out.println(request.getContentType());
out.println("
out.println("");
out.close();
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = new PrintWriter (response.getOutputStream());
out.println("");
out.println("ShowFormdata");
out.println("");
out.println(request.getContentType());
out.println("
");");
BufferedInputStream in = new BufferedInputStream(request.getInputStream());
int c;
while((c=in.read())!=-1)
out.write(c);
out.println("
out.println("");
out.close();
}