Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Wildfly中REST响应的GZip压缩_Java_Rest_Jax Rs_Gzip_Wildfly 8 - Fatal编程技术网

Java Wildfly中REST响应的GZip压缩

Java Wildfly中REST响应的GZip压缩,java,rest,jax-rs,gzip,wildfly-8,Java,Rest,Jax Rs,Gzip,Wildfly 8,我正在编写一个REST服务来发送xml格式的数据列表。我该如何压缩响应 我看到了从文件系统发送zip文件的示例代码,但我想动态构建zip部分。首先查询我的数据库并构建要发送到客户机的xml数据。必须对这些xml数据进行压缩 请告知 File file = new File("Test.zip"); // Build this zip dynamically from the xml data and not from sile system ResponseBuilder response =

我正在编写一个REST服务来发送xml格式的数据列表。我该如何压缩响应

我看到了从文件系统发送zip文件的示例代码,但我想动态构建zip部分。首先查询我的数据库并构建要发送到客户机的xml数据。必须对这些xml数据进行压缩

请告知

File file = new File("Test.zip"); // Build this zip dynamically from the xml data and not from sile system
ResponseBuilder response = Response.ok((Object) file);
response.header("Content-Disposition", "attachment; filename = Test.zip");
return response.build();

只要把这个注释

@GZIP
public class SomeController{
}

如果客户端支持,RESTEasy将自动gzip响应。请看:gzip和zip是不同的东西。gzip是纯压缩,而zip是压缩和归档。这是哪一个?如果你能在代码中添加一些解释,那就更好了。