【问题标题】:SpringMVC generated manifest xml Manifest fetch failed (406)SpringMVC 生成的清单 xml 清单获取失败 (406)
【发布时间】:2015-11-30 15:17:46
【问题描述】:

我正在服务器端生成一个 html5 缓存清单 xml,我得到了 应用程序缓存错误事件:清单提取失败 (406) 此错误消息在我的控制台中。

我的 html 中有这个标签:

<html manifest="http://localhost:8080/test/api/view/view/system/manifest">

我的控制器方法:

@RequestMapping(value = "manifest", produces = "text/cache-manifest", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public String manifest() {
    logger.debug("Generating the manifest file!");

    StringBuilder strManiFstBuilder = new StringBuilder();
    strManiFstBuilder.append("CACHE MANIFEST"); 
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("#revision 1");
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("CACHE:");
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("api/view/view/order");
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("NETWORK:");
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("api/view/view/system/ping");
    strManiFstBuilder.append("\n");
    strManiFstBuilder.append("*");
    strManiFstBuilder.append("\n");

    return strManiFstBuilder.toString();
}

我的 web.xml 中有这个

<mime-mapping>
    <extension>manifest</extension> 
    <mime-type>text/cache-manifest</mime-type>
</mime-mapping>

如果我从浏览器调用控制器方法,则会生成:

缓存清单

缓存: api/view/bestellijstsearchlistview/order/search/template/tags,name,%20customer.naam,orderParts.orderItems.product.description,orderParts.orderItems.product.externalId/page/1/size/500 网络: api/视图/视图/系统/ping *

我必须生成这个文件,我该怎么做?我的解决方案可能有什么问题?

【问题讨论】:

    标签: html spring-mvc manifest offline-browsing


    【解决方案1】:

    我设法解决了这个问题,方法是从注释中删除了produces 属性,并将.manifest 添加到urlname。

    我的控制器的标题:

    @RequestMapping(value = "cache.manifest", method = RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    @ResponseBody
    public String manifest() {
    
    
    <html manifest="http://localhost:8080/system/cache.manifest">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-26
      相关资源
      最近更新 更多