1

我有一个小的 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">
4

0 回答 0