我在一个页面上,我想在点击下载链接时传递参数。
报告?NAME =东西
问题是我无法获取request.getParameter(“name”),因为它已经是另一个链接
那我该怎么做?我需要传递名称
@RequestMapping(value = "/getFile", method = RequestMethod.GET)
public void getSpool(HttpServletRequest request, HttpServletResponse response) {
String environmentName = request.getParameter("name");
String url = Report.getFileFromContainer(environmentName);
try {
InputStream in = new URL(url).openStream();
response.setContentType("application/octet-stream");
response.addHeader("Content-Disposition", "attachment; filename=file-" + environmentName + ".zip");
IOUtils.copy(in, response.getOutputStream());
response.flushBuffer();
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
HTML
<a href="/getFile"></a>
答案 0 :(得分:0)
您应该传递参数。那么只有你才能得到它。这是答案:
**<a href="/getFile?name=INDIA"></a>**