是否可以
将通过fckeditor上传的文件的内容处置设置为"附件"?
我不这么认为。仅适用于 DMS 中的资源。
实际上我只是想出了一个解决方法; 添加一个 servlet 过滤器,将 http 标头属性content-disposition
更改为attachment
,仅此而已!下面是一个代码片段:
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
StringBuffer fileName = new StringBuffer();
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
StringBuffer extension = new StringBuffer(
FilenameUtils.getExtension(req.getRequestURL().toString()));
log.debug("--***-- File extension : " + extension.toString());
if (extension.toString().equalsIgnoreCase("pdf")
|| extension.toString().equalsIgnoreCase(".pdf")) {
fileName.append(FilenameUtils.getBaseName(req.getRequestURL()
.toString()));
log.debug("--***-- PDF file name : " + fileName.toString());
resp.addHeader("Content-Disposition", "attachment; filename="
+ fileName);
}
chain.doFilter(request, resp);
}