在Spring中为缓存添加缓存标头

时间:2013-11-07 15:44:23

标签: java spring caching servlets cache-control

我有一个小的java spring项目,它是一个返回xml响应的API。 想要将Cache-Control标头添加到响应中,但我无法找到方法。 我可以将标题添加到响应中,还是必须将其移动到MVC?

@RequestMapping(method=RequestMethod.GET,value="/search/discountsall", 
        produces="application/xml")
public ModelAndView searchAll() {
    SearchDiscounts discounts = new SearchDiscounts();

    discounts = serviceFacade.getAll();

    ModelAndView mav = new ModelAndView("xmlView");
    mav.addObject("discounts", discounts);

    return mav;
}

这是我的rest-servlet.xml标题:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd">

0 个答案:

没有答案