是否有 spring 3.1 MVC 注释来关闭浏览器响应缓存?

发布于 2024-12-28 07:56:12 字数 376 浏览 3 评论 0原文

SpringMVC 3.1 中是否有一些注释可以关闭 MVC 控制器方法上的浏览器缓存?

@Controller
@RequestMapping("/status")
public class StatusController {

    @RequestMapping(method=RequestMethod.GET)
    //anyway to have an annotation here that turns of all the http caching headers?
    public String get()
    {
            // do some work here 
        return "status";
    }
}

Is there some annotation in SpringMVC 3.1 to turn off browser caching on an MVC controller method?

@Controller
@RequestMapping("/status")
public class StatusController {

    @RequestMapping(method=RequestMethod.GET)
    //anyway to have an annotation here that turns of all the http caching headers?
    public String get()
    {
            // do some work here 
        return "status";
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守望孤独 2025-01-04 07:56:12

据我所知,没有注释,但有一种方法可以使用拦截器通过 XML 配置它。例如:

<mvc:interceptors>
    <mvc:interceptor>
        <mvc:mapping path="/status"/>
        <bean id="noCacheWebContentInterceptor"
                      class="com.nyx.spring.mvc.WebContentInterceptor">
            <property name="cacheSeconds" value="0"/>
            <property name="useExpiresHeader" value="true"/>
            <property name="useCacheControlHeader" value="true"/>
            <property name="useCacheControlNoStore" value="true"/>
        </bean>
    </mvc:interceptor>
</mvc:interceptors>

As far as I can tell there isn't an annotation, but there is a way to configure it via XML using an interceptor. For example:

<mvc:interceptors>
    <mvc:interceptor>
        <mvc:mapping path="/status"/>
        <bean id="noCacheWebContentInterceptor"
                      class="com.nyx.spring.mvc.WebContentInterceptor">
            <property name="cacheSeconds" value="0"/>
            <property name="useExpiresHeader" value="true"/>
            <property name="useCacheControlHeader" value="true"/>
            <property name="useCacheControlNoStore" value="true"/>
        </bean>
    </mvc:interceptor>
</mvc:interceptors>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文