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).
精彩评论