当前位置: 代码迷 >> Java Web开发 >> 怎么从HttpServletRequest中获取图片
  详细解决方案

怎么从HttpServletRequest中获取图片

热度:373   发布时间:2016-04-17 12:29:14.0
如何从HttpServletRequest中获取图片
客户端提交一个图片到一个servlet,从这个servlet中怎么获取到上传的图片?代码如下:
客户端:
<form id="form1" name="form1" action="upload.action" method="post" enctype="multipart/form-data">
<input type="file" name="f" id="f" />
<input type="submit" name="s" id="s" value="提交" />
</form>

upload.action:
public class OImg extends HttpServlet {
  public void doPost(HttpServletRequest req, HttpServletResponse res)
  throws ServletException, IOException {
System.out.println("ContentLength: " + req.getContentLength());
  //????????怎么获取上传的图片??
  }
}

------解决方案--------------------
用smartUpload 之类的上传组件!

去google 搜索
smartupload

http://dev.csdn.net/develop/article/18/18987.shtm
  相关解决方案