我有一个扩展RequestHandlerBase的自定义请求处理程序。
此处理程序的目的是搜索给定用户查询的索引。响应数据应该以文件的形式下载,而不是省略客户端浏览器上的结果。下面是我的handleRequestBody函数代码
@Override
public void handleRequestBody(final, SolrQueryRequest req,final SolrQueryResponse res) {
tempFile = File.createTempFile(UUID.randomUUID().toString(),".tmp", new File(FILE_PATH));
writeSearchResultstoFile(tempFile);
ContentStreamBase outConentStream = new ContentStreamBase.FileStream(tempFile);
outConentStream.setContentType("application/download");
rsp.add(RawResponseWriter.CONTENT, outConentStream);
}问题是该文件在客户端与.part文件一起下载。rsp.getResponseHeader().add("Content-Disposition","filename=data.csv");
帮不了多少忙。能告诉我如何设置内容配置吗?
发布于 2012-02-09 23:36:55
由于我看到您正在将结果格式化为CSV,我很好奇您是否查看过Solr从3.1版开始支持的CSVResponseFormat
https://stackoverflow.com/questions/9210177
复制相似问题