我有一個REST方法,我想輸出gziped內容。我已經在web.xml中添加爲什麼我的回覆在使用GZIPContentEncodingFilter時沒有壓縮
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.GZIPContentEncodingFilter</param-value>
</init-param>
到servlet
我可以看到,該代碼會突破的GZIPContentEncodingFilter類的調試輸出,但沒有得到.GZIP前綴和內容沒有被壓縮,而不是這是正常的json。我正在使用澤西島1.14。
方法是這樣的:
@GET
@Path("/fundlight")
@Produces(MediaType.APPLICATION_JSON)
public Response getFundLightList() {
StopWatch watch = new StopWatch();
watch.start();
Collection<Object> objectResults = null;
objectResults = getCacheMap("FundLight").values();
List<FundLight> fundLightList = new ArrayList(objectResults);
watch.stop();
GenericEntity<List<FundLight>> entity = new GenericEntity<List<FundLight>>(fundLightList) {
};
ResponseBuilder builder = Response.ok(entity);
return builder.build();
}