ContainerRequestFilter ContainerResponseFilter doesn't get called

前端 未结 4 936
感动是毒
感动是毒 2020-12-09 10:59

I am trying to learn jersey by creating a small RESTful service. I want to use the Filters for specific reasons(Like I want to use the ContainerResponseFilter

4条回答
  •  爱一瞬间的悲伤
    2020-12-09 11:25

    I added a Jersey Application class and registered the filter in the class, which solved my problem. Also upgraded my jersey version to 2.x from 1.x

    public class MyApplication extends ResourceConfig {
    
        /**
         * Register JAX-RS application components.
         */
        public MyApplication () {
            register(RequestContextFilter.class);
            register(JacksonFeature.class);
            register(CustomerResource.class);
            register(Initializer.class);
            register(JerseyResource.class);
            register(SpringSingletonResource.class);
            register(SpringRequestResource.class);
            register(CustomExceptionMapper.class);
        }
    }
    

提交回复
热议问题