1

我在服务器端生成一个 html5 缓存清单 xml,我收到 Application Cache Error 事件:Manifest fetch failed (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 *

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

4

1 回答 1

0

我设法通过从注释中删除生产属性来解决此问题,并将 .manifest 添加到 urlname。

我的控制器的标题:

@RequestMapping(value = "cache.manifest", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public String manifest() {


<html manifest="http://localhost:8080/system/cache.manifest">
于 2015-09-07T09:23:17.533 回答