我发送HTTP GET请求,期望将Excel工作簿作为响应。但是,响应格式不正确。我期待下载提示作为响应
@GET
@Path("bulkimporttemplate")
@Produces("application/vnd.ms-excel")
public Response getClientTemplate() throws IOException {
final XSSFWorkbook wb = new XSSFWorkbook();
WorkbookPopulatorFactory.createWorkbookPopulator("Client", "ClientTemplate");
StreamingOutput streamOutput = new StreamingOutput() {
@Override
public void write(OutputStream out) throws IOException, WebApplicationException {
wb.write(out);
}
};
ResponseBuilder response = Response.ok(streamOutput, "application/vnd.ms-excel");
response.header("content-disposition", "attachment; filename=clientTemplate.xls");
return response.build();
}