Java Windows Phone 8从web下载文件

Java Windows Phone 8从web下载文件,java,html,spring,windows-phone-8,mobile-website,Java,Html,Spring,Windows Phone 8,Mobile Website,我们使用java/spring开发移动web应用程序,在WindowsPhone8上下载pptx、xls等文件时遇到问题 在HTML中,我们有这样的简单代码 <div> <a class="attchLink ui-link" target="_blank" href="/rest/item/DOCID159636/attachment/presentation.pptx">presentation.pptx</a> </div> 在我们测试

我们使用java/spring开发移动web应用程序,在WindowsPhone8上下载pptx、xls等文件时遇到问题

在HTML中,我们有这样的简单代码

<div>
<a class="attchLink ui-link" target="_blank" href="/rest/item/DOCID159636/attachment/presentation.pptx">presentation.pptx</a>
</div>

在我们测试的所有手机(iPhone 4S、5、三星Galaxy 4、mini、Windows phone 7)上,它都可以正常工作,但在配备Windows phone 8的诺基亚手机上,我们有时会在图标选项卡上卡住,无法打开下载文件后显示的witch。PPTX文件的大小约为500KBs,所以文件大小不会有问题,有时手机会(15%)打开它


有人知道这个问题是可以解决的,还是只是windows phone 8中Microsoft端的bug?

很可能您没有在下载的http头中设置文件的内容大小

  @RequestMapping(value = "download/{id}", method = RequestMethod.GET)
  public HttpEntity<byte[]> download(@PathVariable("id") int documentId) {

         /* or how ever you access the content */
         byte[] content = this.documentService.loadDocumentContent(documentId)

         HttpHeaders headers = new HttpHeaders();
         headers.setContentType( /* depending on your document */ );
/* -> */ headers.setContentLength(content.length); /* <-- that's the point */  
         headers.set("Content-Disposition", "attachment; filename=\"test.ppt\"");

         return new HttpEntity<byte[]>(content, headers);
}
@RequestMapping(value=“download/{id}”,method=RequestMethod.GET)
公共HttpEntity下载(@PathVariable(“id”)int-documentId){
/*或者你是如何访问内容的*/
字节[]内容=this.documentService.loadDocumentContent(documentId)
HttpHeaders=新的HttpHeaders();
headers.setContentType(/*取决于您的文档*/);

/*->*/headers.setContentLength(content.length)来自rest api的响应看起来像
状态代码:200 OK Cache Control:max age=0,无缓存,无存储内容长度:791775内容类型:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet日期:2013年11月28日星期四09:37:46 GMT过期时间:1970年1月1日00:00 GMT Pragma:no Cache Server:Apache-Coyote/1.1
可以设置最后一个字节。我们设置了内容长度,在同一个文件上进行100次尝试后,它仍然只能工作一次…我们正在通过@ResponseBody注释添加这些标题,它们看起来很好…我尝试像您的示例中那样手动设置它们,并且它也提供了帮助。。。