资源简介
使用commons-fileupload实现的文件上传和下载,上传和下载都没有中文乱码问题
代码片段和文件信息
/**
* Program : DownServlet.java
* Author : yinhailong
* Create : 2010-6-30 ����08:55:55
*
* Copyright 2006 by embedded Internet Solutions Inc.
* All rights reserved.
*
* This software is the confidential and proprietary information
* of embedded Internet Solutions Inc.(“Confidential Information“).
* You shall not disclose such Confidential Information and shall
* use it only in accordance with the terms of the license agreement
* you entered into with embedded Internet Solutions Inc.
*
*/
package com.hailong.fileupload.servlet;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author yinhailong
* @version 1.0.0
* @2010-6-30 ����08:55:55
*/
public class DownServlet extends HttpServlet
{
/**
* @author yinhailong
* @create 2010-6-30 上午09:09:19
* @since
*/
private static final long serialVersionUID = 1L;
/**
* Constructor of the object.
*/
public DownServlet()
{
super();
}
/**
* Destruction of the servlet.
*/
public void destroy()
{
super.destroy(); // Just puts “destroy“ string in log
// Put your code here
}
/**
* The doGet method of the servlet.
*
* This method is called when a form has its tag value method equals to get.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
{
this.doPost(request response);
}
/**
* The doPost method of the servlet.
*
* This method is called when a form has its tag value method equals to
* post.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException IOException
{
response.reset();
response.setContentType(“text/html;charset=utf-8“);
response.setCharacterEncoding(“utf-8“);
String filePath = request.getParameter(“filePath“);
if (filePath == null)
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 428 2010-06-30 11:31 fileupload\.classpath
文件 303 2010-06-30 11:31 fileupload\.myme
文件 1228 2010-06-30 09:07 fileupload\.project
文件 88 2010-06-30 08:56 fileupload\.settings\org.eclipse.core.resources.prefs
文件 4220 2010-06-30 11:26 fileupload\src\com\hailong\fileupload\servlet\DownServlet.java
文件 5986 2010-06-30 11:37 fileupload\src\com\hailong\fileupload\servlet\UpServlet.java
文件 382 2010-06-30 10:42 fileupload\WebRoot\error.jsp
文件 868 2010-06-30 09:27 fileupload\WebRoot\index.jsp
文件 39 2010-06-30 08:54 fileupload\WebRoot\me
文件 523 2010-06-30 10:48 fileupload\WebRoot\success.jsp
文件 665 2010-06-30 10:41 fileupload\WebRoot\upFile.jsp
文件 2749 2010-06-30 11:39 fileupload\WebRoot\WEB-INF\classes\com\hailong\fileupload\servlet\DownServlet.class
文件 3912 2010-06-30 11:39 fileupload\WebRoot\WEB-INF\classes\com\hailong\fileupload\servlet\UpServlet.class
文件 22379 2010-06-30 09:05 fileupload\WebRoot\WEB-INF\lib\commons-fileupload-1[1].0.jar
文件 1119 2010-06-30 08:55 fileupload\WebRoot\WEB-INF\web.xm
目录 0 2010-06-30 11:39 fileupload\WebRoot\WEB-INF\classes\com\hailong\fileupload\servlet
目录 0 2010-06-30 11:39 fileupload\WebRoot\WEB-INF\classes\com\hailong\fileupload
目录 0 2010-06-30 11:26 fileupload\src\com\hailong\fileupload\servlet
目录 0 2010-06-30 11:39 fileupload\WebRoot\WEB-INF\classes\com\hailong
目录 0 2010-06-30 08:54 fileupload\src\com\hailong\fileupload
目录 0 2010-06-30 11:39 fileupload\WebRoot\WEB-INF\classes\com
目录 0 2010-06-30 08:54 fileupload\src\com\hailong
目录 0 2010-06-30 11:39 fileupload\WebRoot\WEB-INF\classes
目录 0 2010-06-30 09:05 fileupload\WebRoot\WEB-INF\lib
目录 0 2010-06-30 08:54 fileupload\src\com
目录 0 2010-06-30 08:54 fileupload\WebRoot\me
目录 0 2010-06-30 08:54 fileupload\WebRoot\WEB-INF
目录 0 2010-06-30 08:54 fileupload\.myeclipse
目录 0 2010-06-30 08:56 fileupload\.settings
目录 0 2010-06-30 08:54 fileupload\src
............此处省略5个文件信息
评论
共有 条评论