简体   繁体   English

Java Jersey和Servlet过滤器

[英]Java Jersey and servlet filters

I'm planning to build a REST API based on Jersey to replace a previous servlet-based API. 我计划构建一个基于Jersey的REST API,以替换以前的基于Servlet的API。 However, I have some filters which are applied to the servlet-based API: an encryption/decryption filter and a GZIP filter. 但是,我有一些应用于基于servlet的API的过滤器:加密/解密过滤器和GZIP过滤器。 Since these filters are servlet filters, can I keep them and expect them to work with Jersey just like the previous servlet model, or there are any issues related to this? 由于这些过滤器是servlet过滤器,因此我可以保留它们并希望它们像以前的servlet模型一样与Jersey一起使用,还是有与此相关的任何问题? Can servlet filtering be directly applied to Jersey without any modifications? 可以在不做任何修改的情况下将servlet筛选直接应用于Jersey吗?

JERSEY does not mandate to use any of its filter, which can create a conflict with user defined filters. JERSEY并不要求使用其任何过滤器,否则可能会与用户定义的过滤器产生冲突。 Jersey requires only to configure the framework servlet and NO filters in web.xml. Jersey只需要在web.xml中配置框架servlet和NO过滤器。 I have used Jersey with my own filter implementations for things like authentication. 我已经将Jersey与我自己的过滤器实现一起用于身份验证之类的事情。 It works like a charm, so don't worry. 它就像一种魅力,所以不用担心。

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

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