Java HttpServletResponse在保存时提示输入文件名

Java HttpServletResponse在保存时提示输入文件名,java,spring-mvc,servlets,Java,Spring Mvc,Servlets,我使用了类似于下面的代码,将zip文件作为SpringMVC请求的附件返回。这一切都很好,当我向localhost/app/getZip发出请求时,我可以下载一个名为hello.zip的文件 我的问题是,如何提示用户输入文件名。目前在FireFox25.0上,它自动假定名称为“hello.zip”,而没有在打开或保存选项时更改文件名的规定 @RequestMapping("getZip") public void getZip(HttpServletResponse respon

我使用了类似于下面的代码,将zip文件作为SpringMVC请求的附件返回。这一切都很好,当我向localhost/app/getZip发出请求时,我可以下载一个名为hello.zip的文件

我的问题是,如何提示用户输入文件名。目前在FireFox25.0上,它自动假定名称为“hello.zip”,而没有在打开或保存选项时更改文件名的规定

    @RequestMapping("getZip")
    public void getZip(HttpServletResponse response)
    {
        OutputStream ouputStream;
        try {
            String content = "hello World";
            String archive_name = "hello.zip";
            ouputStream = response.getOutputStream();
            ZipOutputStream out = new ZipOutputStream(ouputStream);
            out.putNextEntry(new ZipEntry(“filename”));
            out.write(content);
            response.setContentType("application/zip");
            response.addHeader("Content-Disposition", "attachment; filename="+ archive_name);
            out.finish();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

TL;DR:使用HttpServletResponse,我希望用户提供一个文件名,而不是在头中传递一个文件名。

with method to RequestMethod.GET
URL:
http://localhost/app/getZip?filename=hello.zip

@RequestMapping(value = "getZip/{filename}", method = RequestMethod.GET)
public void getZip(HttpServletResponse response, @PathVariable String filename)
{
    OutputStream ouputStream;
    try {
        String content = "hello World";
        String archive_name = "hello.zip";
        ouputStream = response.getOutputStream();
        ZipOutputStream out = new ZipOutputStream(ouputStream);
        out.putNextEntry(new ZipEntry("filename"));
        out.write(content);
        response.setContentType("application/zip");
        response.addHeader("Content-Disposition", "attachment; filename="+ archive_name);
        out.finish();
        out.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}