How to handle CORS using JAX-RS with Jersey

后端 未结 5 724
北荒
北荒 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:38

    Remove annotation "@CrossOriginResourceSharing(allowAllOrigins = true)"

    Then Return Response like below:

    return Response.ok()
                   .entity(jsonResponse)
                   .header("Access-Control-Allow-Origin", "*")
                   .build();
    

    But the jsonResponse should replace with a POJO Object!

提交回复
热议问题