文件上传,找个包或者自己做个class都可以
解决方案 »
- 求解决springMVC 中出现getOutputStream() has already been called for this response的问题。
- javabean的属性变量为什么都设置为private,为什么不是public
- java中怎样取得服务器IP分发的实际IP和端口地址
- 求助:session为null问题
- jsp中如何能正确输出sqlserver的datatime值?
- 请问关于网络方面的书哪本最为权威?请求指点。
- smartUpload 怎么出现如此错误?
- 哪位高手能提供EJB的例子,在线等
- 请问这个错误:[Microsoft][ODBC 驱动程序 管理器] 非法的游标状态。是怎么回事?
- 34分求教简单问题(字符串转换为16进制),help!!!
- 理解结贴--关于自动提醒功能
- 求救:用JSP获取的特定网站的HTML内容
所以你要对这些表单进行分类.
具体怎么弄.俺也不知道.
private static final String CONTENT_TYPE = "text/html; charset=GBK";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>streamRead</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.println("<p>The servlet has received a " + request.getMethod() + ". This is the reply.</p>");
out.println("</body></html>");
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
byte mStream[]=null;
int totalRead = 0;
int readBytes = 0;
int totalBytes = 0;
try
{
totalBytes = request.getContentLength();
System.out.println(totalBytes);
mStream = new byte[totalBytes];
while (totalRead < totalBytes) {
request.getInputStream();
readBytes = request.getInputStream().read(mStream, totalRead,
totalBytes - totalRead);
totalRead += readBytes;
}
String filename=request.getParameter("filename");
System.out.println(filename);
FileOutputStream fs;
fs = new FileOutputStream("d:/"+filename);
fs.write(mStream);
fs.flush();
fs.close();
OutputStream OutBinarry=response.getOutputStream() ;
OutBinarry.write(mStream) ;
OutBinarry.flush();
OutBinarry.close();
} catch (Exception e)
{
System.out.println(e.toString());
} }
//Process the HTTP Put request
public void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("begin to execute put method!"); } //Process the HTTP Delete request
public void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("begin to execute delete method!");
}
//Clean up resources
public void destroy() {
}