演示代码如下: Flex端: private function downloadFile(downloadfile : String) : void{ /** URLの処理*/ commonUtils.encodeUrlParam(downloadfile, "UTF-8"); } private function resultEncodeUrlParam(event:ResultEvent) : void { var param : String = event.result as String; navigateToURL(new URLRequest(encodeURI('./filedownload?filename=' + param + '&messageno=2')), '_self'); } Java端: CommonUtils.java中追加一个方法: public String encodeUrlParam(String param, String encoding) throws UnsupportedEncodingException { return URLEncoder.encode(param, encoding); } 文件下载用的Servlet: public class FileDownloadServlet extends HttpServlet { private static final long serialVersionUID = 1103536900069010631L; private static final Log log = LogFactory.getLog(FileDownloadServlet.class); @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { processRequest(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { processRequest(req, resp); } /** ファイルダウンロード処理ロジック */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setHeader("pragma", "no-cache"); response.setHeader("cache-control", "no-cache"); response.setDateHeader("Expires", 0); request.setCharacterEncoding("UTF-8"); String filename = request.getParameter("filename"); String messageno = request.getParameter("messageno"); if (filename == null || "".equals(filename.trim())) { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); out.println("<font color=red>添付ファイルが存在しない。</font>"); out.close(); return; } else { /** ダウンロードファイルパスを取得する */ String filepath = getUploadFilePath(messageno); response.reset(); response.setContentType("application/octet-stream;charset=UTF-8"); response.setHeader("Content-disposition","attachment;filename=" + filename); BufferedInputStream bis = null ; BufferedOutputStream bos = null ; try { filename = URLDecoder.decode(filename, "UTF-8"); bis = new BufferedInputStream(new FileInputStream(filepath + "/" +filename)); bos = new BufferedOutputStream(response.getOutputStream()); byte[] buffer = new byte[4096]; int bytesRead; while ( - 1 != (bytesRead = bis.read(buffer, 0, buffer.length))) { bos.write(buffer, 0 , bytesRead); } } catch (IOException e) { e.printStackTrace(); } finally { if(bis != null) bis.close(); if(bos != null) bos.close(); } } } /** ファイルダウンロードパスを用意する */ private String getUploadFilePath(String messageno) { ResourceBundle bundle = null; try { bundle = ResourceBundle.getBundle("nauproject"); if(bundle == null) return null; } catch (Exception e) { log.error("ファイルダウンロード用パスを読む際にエラーが発生しました。"); e.printStackTrace(); } String filepath = bundle.getString("InfoTempFile_file"); if(filepath.endsWith("/")) { filepath = filepath + messageno; } else { filepath = filepath + "/" +messageno; } File uploadfile = new File(filepath); if(!uploadfile.exists()) uploadfile.mkdirs(); return filepath; } }