这样修改试一试:
 <servlet-mapping>
    <servlet-name>download</servlet-name>
    <url-pattern>/download/*</url-pattern><!--here edited-->
  </servlet-mapping>

解决方案 »

  1.   

    不可以把Download的源代码给帖出来吗?
      

  2.   

    部署没有问题:
    源代码:(提示这是 fuzhe(令狐虫) 在这转帖,和我修改一两个地方)import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;public class Download extends HttpServlet {        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 {
                    //HttpServletRequestWrapper httpReqWrapper = (HttpServletRequestWrapper) request;
                    //HttpServletRequest httpRequest =(HttpServletRequest)httpReqWrapper.getRequest();
                    try {
                          downloadArtifact(request, response);
                }catch (Exception e) {
                  e.printStackTrace();
                  RequestDispatcher dispatcher = this.getServletContext().
                  getRequestDispatcher("/Error.jsp");
                  dispatcher.forward(request, response);//              httpServletRequest.setAttribute("message", "修改密码错误!");
    //              return (actionMapping.findForward("unknown-error"));
                }
        }     public void downloadArtifact(HttpServletRequest request, HttpServletResponse response)
                  throws Exception {
                Exception ex=null;
                String fileId = (String)request.getParameter("ID");
                String realFile = null;
                String realFileName = "";
                File uploadDir = new File("D:\\upload");
                if (uploadDir.isDirectory()) {
                        File[] files = uploadDir.listFiles();
                        for (int j = 0; j < files.length; j++) {
                                File tempFile = files[j];
                                if ((tempFile.getName().indexOf(fileId)) >= 0){
                                        //System.err.println("get The file" + tempFile.getName());
                                        realFile = tempFile.getName();
                                        break;
                                }
                        }
                }
                int seperatePos = realFile.lastIndexOf(".");
                String fileAppendix = realFile.substring(seperatePos+1);
                String tempFileName = realFile.substring(0,seperatePos);
                int idIndex = tempFileName.lastIndexOf(fileId);
                realFileName = tempFileName.substring(0,idIndex) + "." + fileAppendix;            realFile = "emCnGoList.xls";  //add by ander  rewrite the realFile            File file = new File("D:\\upload", realFile);
                if(!file.exists()) throw new Exception("Sorry, File Not Found");
                int length=(new Long(file.length())).intValue();
                response.setContentType("application/octet-stream; charset=UTF-8");
                response.setHeader("Content-disposition", "attachment; filename=\""+realFileName+"\"");
                //response.setHeader("Content-disposition", "attachment; filename=\""+file.getName()+"\"");
                //System.err.println("******" + realFileName);
                int bufferSize=1024;
                BufferedOutputStream output = null;
                BufferedInputStream input = null;
                output = new BufferedOutputStream(response.getOutputStream());
                input = new BufferedInputStream(new FileInputStream(file));
                try {
                  int once = 0;
                  int total = 0;
                  byte[] buffer = new byte[bufferSize];
                  do {
                    once = input.read(buffer);
                    total += once;
                    if (once >= 0)
                      output.write(buffer, 0, bufferSize);
                    }
                    while ( (total < length) && (once >= 0));
                      response.flushBuffer();
                    }
                    catch (Exception e) {
                      ex = e;
                    } // maybe user cancelled download
                    finally {
                      if (input != null) input.close();
                      if(output!=null) output.close();
                      if(null!=ex) throw ex;
                    }
        }
    //Process the HTTP Post request
      public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
      }
    }
      

  3.   

    <form action="download" ...>把“/download”前面的“/”去掉,可能是路径影射问题