开发者

jersey does support treturn gzip byte

开发者 https://www.devze.com 2023-04-13 08:05 出处:网络
current now i used response to return a xml file . but seems the performance is not good when file is lager.

current now i used response to return a xml file . but seems the performance is not good when file is lager. so i would like know that how to return a byte[] (gzip /xml) also the IE/firefox can dispaly this xml file from gzip byte array

before i use servlet it can auto show the xml file

@GET
@Path("/Test/{CustomerId}")
@Produces("application/xml")
public Response getTest() throws IOException {
    return Response.ok().entity(new FileInputStream("CC100_PC开发者_JAVA百科.xml")).build();

}

by the way Jersey how to support init and Destroy function , i want add some database connection into init function and destroy it


Just add the GZIPContentEncodingFilter to your Jersey app - see http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/container/filter/GZIPContentEncodingFilter.html

That will automatically compress it using GZIP if the client supports it (which it figures out from the Accept-Encoding HTTP header).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号