【问题标题】:How to cache a spring MVC application with html 5?如何使用 html 5 缓存 Spring MVC 应用程序?
【发布时间】:2013-07-05 07:50:47
【问题描述】:

我想使用 HTML5 标准为我的 Spring MVC 应用程序构建一个缓存。

我的项目架构如下:

在我的 web.xml 中我添加了这个:

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

我在 WEB-INF 文件夹中创建了一个 .manifest 文件,其中包含

CACHE MANIFEST
 # version 1

CACHE:
home.jsp
css/style.lesss

home.jsp 文件头是:

<html manifest="collabook.manifest">

没有文件被缓存(safari web 检查器)

如何实现我的目标?

谢谢

【问题讨论】:

    标签: html spring caching spring-mvc


    【解决方案1】:

    另外,将此添加到您的 dispatcher-servlet.xml:

    <resources mapping="/files/to/cache/**" location="/files/to/cache/"
    

    并将其添加到您的视图解析器中:

    <bean id="myview"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/files/to/cache/</value>
        </property>
        <property name="suffix">
            <value>.manifest</value>
        </property>
        <property name="order">
            <value>1</value>
        </property>
    </bean>
    

    如果你想为动态内容做一些自定义的事情,你还需要一个 MVC 控制器来获取 URI。

    【讨论】:

    • 当我添加 bean 时,我的 jsp 页面既不显示也不缓存
    • 在您添加此内容之前是否已显示?根据您上面的内容,我认为前缀需要是“collabook”。
    猜你喜欢
    • 2019-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-12
    • 1970-01-01
    • 1970-01-01
    • 2014-09-26
    • 2013-10-10
    相关资源
    最近更新 更多