membersound membersound - 1 year ago 1405
Java Question

How to enable GZIP for RestController?

I'm having a simple

controller using
How could GZIP response of the returned
stream be enabled?

public class MyRest {
@RequestMapping(method = RequestMethod.GET,
produces = MediaType.APPLICATION_XML_VALUE)
public ComplexRsp test() {

When using soap+wsdl approach, there would be the simple
annotation on the service class. How can I achieve the same for REST?

Answer Source

If you are using Spring boot and Tomcat You should be able to accomplish this via Tomcat Configuration:

Here is a similar POST Using GZIP compression with Spring Boot/MVC/JavaConfig with RESTful

It's as simple as follows: