简体   繁体   English

带有Apache CXF的JAX-WS RS-GZIP压缩

[英]JAX-WS RS with Apache CXF - GZIP Compression

I'm creating a RESTFul WS using JAX-RS with Apache CXF. 我正在使用JAX-RS和Apache CXF创建RESTFul WS。 I want to be able to compress the data being returned. 我希望能够压缩返回的数据。 An example of my code is: 我的代码示例是:

 @POST  
 @Path("testGZIPMethod")
 @GZIP
 @Produces(MediaType.APPLICATION_JSON)  
 public String testGZIPMethod(@FormParam("userinput")String userinput)  
 {
     //return JSON String
 }

When i try to compile my class using JDev, i get the following error: annotation type not applicable to this kind of declaration. 当我尝试使用JDev编译类时,出现以下错误:注释类型不适用于这种声明。 The annotation causing this error is @GZIP. 引起此错误的注释为@GZIP。 Any idea where to move on from here? 知道从这里继续前进吗?

The @GZIP annotation can only be applied to types and not to methods: @GZIP批注只能应用于类型,而不能应用于方法:

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface GZIP {
    int threshold() default -1;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM