日期:2014-05-17 浏览次数:20793 次
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@page import="com.jspsmart.upload.SmartUpload"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'do_download.jsp' starting page</title> </head> <body> <% SmartUpload smartUpload = new SmartUpload(); smartUpload.initialize(pageContext); smartUpload.setContentDisposition(null); //不让其自动显示 smartUpload.downloadFile("upload/1.gif"); %> </body> </html>
------解决方案--------------------
把编码先统一了,输出的时候,对流再进行一次编码。
------解决方案--------------------
response.addHeader("Content-Disposition","attachment;filename="+file.getName());
我记得这里的文件名要用Urlencoding
------解决方案--------------------
输出流用UTF-8进行编码即可
------解决方案--------------------
String name=new String(request.getParameter("name").getBytes(),“ISO8859-1”);
------解决方案--------------------
response.addHeader("Content-Disposition","attachment;filename="+URLEncoder.encode(file.getName(),"UTF-8"));
------解决方案--------------------
直接把我做过的例子贴出来给你吧!
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class FileDownServlet extends HttpServlet {
private static final String