How to handle CORS using JAX-RS with Jersey

后端 未结 5 615
北荒
北荒 2020-11-22 02:01

I\'m developing a java script client application, in server-side I need to handle CORS, all the services I had written in JAX-RS with JERSEY. My code:

@Cross         


        
5条回答
  •  无人及你
    2020-11-22 02:24

    The other answer might be strictly correct, but misleading. The missing part is that you can mix filters from different sources together. Even thought Jersey might not provide CORS filter (not a fact I checked but I trust the other answer on that), you can use tomcat's own CORS filter.

    I am using it successfully with Jersey. I have my own implementation of Basic Authentication filter, for example, together with CORS. Best of all, CORS filter is configured in web XML, not in code.

提交回复
热议问题