我有两个(独立的)Projetcs:
1.。)包含许多链接的JSF-WebApplication
<h:outputLink value="#{file.servletLinkWithParameters}">
<h:outputText value="#{file.caption}"/>
</h:outputLink>
2.。)Filedownload-Servlet,通过附件返回我的文件:
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
....
response.setContentType("application/force-download");
response.setContentLength(realFilesize);
response.setHeader("Content-disposition", "attachment; filename="
+ realFilename);
final OutputStream out = response.getOutputStream();
URL url = new URL(realFilepath);
InputStream in = url.openStream();
final byte[] buffer = new byte[4096];
int length;
while ((length = in.read(buffer)) != -1) {
out.write(buffer, 0, length);
}
in.close();
out.flush();
out.close();
}
当我尝试点击outputLink(例如url:8080 / FileDownloadHandler / download?id = R0RcGAAD)时,它会给我&#34; Unknown Adress&#34;。
但是当我在新窗口或标签中打开相同的链接时,它可以正常工作。
我不知道为什么......