How can I set the response header for each call in my application made with Spring Boot? I would like to try to use a filter to intercept all the calls and be able to set the response header. I followed the guide Disable browser caching HTML5, but only set the request header, and not always.
相关问题
- Dependency injection into Logback Appenders with S
- Deserialize duplicate keys to list using Jackson
- How can I access the repository from the entity in
- Prevent Swagger from automatically adding some mod
- Creating Unknown Number of Beans With Configuratio
相关文章
- How to load @Configuration classes from separate J
- Using Spring Dynamic Languages Support from Groovy
- Spring JMS : Set ErrorHandler for @JmsListener ann
- Google Chrome Cache
- ModelMapper: Choose mapping based on Child class
- Why does Google Chrome NOT use cached pages when I
- Configure Spring for CORS
- Remove transitive classpath dependency in gradle
Implement Filter and is registered by
@Component
annotation. The@Order(Ordered.HIGHEST_PRECEDENCE)
is used for Advice execution precedence.There are three ways to do this:
Set the response for a specific controller, in the Controller class:
or
The last way I found is using an Interceptor that extends HandlerInterceptorAdapter; for more info see https://www.concretepage.com/spring/spring-mvc/spring-handlerinterceptor-annotation-example-webmvcconfigureradapter
I hope I was helpful!