Tag: jax rs

为什么在浏览器中使用JAX-RS和标准servlet时没有显示popup窗口?

当我尝试使用standard servlet approach ,在我的浏览器中popup窗口显示询问是否打开.xls文件或保存它。 我通过JAX-RS尝试了完全相同的代码,并且浏览器popup窗口不会以某种方式显示出来。 有没有人遇到过这个? JAX-RS的方式,不会显示popup: @Path("excellaTest") public class ExcellaTestResource { @Context private UriInfo context; @Context private HttpServletResponse response; @Context private HttpServletRequest request; public ExcellaTestResource() { } @Path("horizontalProcess") @GET //@Produces("application/vnd.ms-excel") @Produces("application/vnd.ms-excel") public void getProcessHorizontally() { try { URL templateFileUrl = this.getClass().getResource("myExcelTemplate.xls"); String templateFilePath = URLDecoder.decode(templateFileUrl.getPath(), "UTF-8"); String outputFileDir = "MasatoExcelHorizontalOutput"; ReportProcessor reportProcessor = new […]

使用csv文件格式化问题

好的,我已经检查了这个问题 ,但是它一点都没有帮到我。 我需要获得一个CSV文件给用户,所以他们可以将其导出到PeopleSoft。 其中一个字段(batch_id)必须为4位数字,并且当前Excel不断删除这些前导零。 我也在TextPad中打开了csv文件,并validation了那些零不见了。 所以inheritance过程: 浏览器指向myapp / Batch / course,如下所示: @GET @Path( "Batch/{course}" ) @Produces( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ) @HttpHeader( values="Content-Disposition=attachment;filename=Batch.csv" ) public String getNextBatch ( @PathParam( "course" ) String course ) { … } 在该方法中,查询Oracle数据库并将数据作为XML发回(在XML中,batch_id的位数是正确的)。 然后,该XML通过StringBuffer.append()处理成一个逗号分隔的长string,然后该方法返回。 @Produces属性使用该string,并确保Excel处理它,并下载文件。 我可以通过在每个逗号后添加制表符来使其显示为4位数字,但是当它加载到PeopleSoft时会popup。 我也可以得到它正确的4位数字,如果我单引号(无论是单引号或引用整个batch_id),但又是PeopleSoft上传的问题。 更多信息:我正在附加数据(但在一个循环): NodeList participants = XmlUtil.selectNodeList( doc, "Batch/row" ); buffer.append( "\t" + item.getAttribute( "batchid" ) ); 有没有人有任何想法如何让Excel的行为正确? […]

JAX-RS POST无法将空xlsx作为MIMEtypes返回

这是我的JAX-RS GET服务的代码 @GET @Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") @Path("/xlsReport") public Response viewXlsReport(@QueryParam("paymentIds")String paymentIds) throws IOException { List spaymentIds = Arrays.asList(paymentIds.split(",")); XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet s1 = wb.createSheet("Some Details"); File f = new File("Some Details.xslx"); FileOutputStream fos = new FileOutStream(f); wb.write(fos); fos.close(); return Response.ok((Object)file).build(); } 和POST服务是一样的 @POST @Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") @Path("/exportReport") @Consumes(MediaType.APPLICATION_JSON) public Response viewXlsReport(String ids) throws IOException { List<string> […]