日期:2014-05-16 浏览次数:20358 次
import java.io.IOException; import org.springframework.http.HttpOutputMessage; import org.springframework.http.converter.HttpMessageNotWritableException; import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; public class NoCacheMappingJacksonHttpMessageConverter extends MappingJacksonHttpMessageConverter { @Override protected void writeInternal(Object o, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { outputMessage.getHeaders().set("Cache-Control", "no-cache"); super.writeInternal(o, outputMessage); } }
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <bean class="org.springframework.http.MediaType"> <constructor-arg value="text"/> <constructor-arg value="plain"/> <constructor-arg value="utf8"/> </bean> </list> </property> </bean> <!-- <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/> --> <bean class="com.fpi.mespvc.web.util.NoCacheMappingJacksonHttpMessageConverter"/> </list> </property> </bean>