1. how to configure Jersey 1.9 to support HTTP access control CORS (Cross-Origin Resource Sharing)
  2. source
    I have created an archetype project to exemplify just that.
  3. how to configure JAX-RS services for deployment in a Web container
  4. This answer to a question of mine in SO is very thorough.
  5. SPA / REST interplay with alternate Tomcat / JBoss deployments and CORS configuration for a Jersey 2 application
  6. Checkout this project in my playground that shows how to achieve interplay between a SPA application and a REST backend using the Jersey 2 JAX-RS implementation under a variety of CORS configuration approaches (and also attempting but not succeeding to achieve deployment in both Tomcat and JBoss EAP 6.2).
  7. SPA / REST interplay with an JBoss EAP 6.4.0 deployment and CORS configuration for a RESTEasy application
  8. Checkout this project in my playground that shows how to achieve interplay between a SPA application and a REST backend using the RESTEasy JAX-RS implementation and deployed in the JBoss EAP 6.4.0 server.

    Also, this particular application (further into the above project) shows how to achieve JAX-RS deployment with the RESTEasy implementation using either the "scanner" or the "application" approach.

    In the context of this travail, I posted this SO question and drew heavily (but not without changes) from this blog post.

  9. configuration for Jersey 2 in Tomcat 8.5
  10. notes for a particular configuration of Jersey 2 in Tomcat 8.5 (December 2016)
  11. annotation corresondances between Spring MVC and JAX-RS
  12. Sources: 1, 2, 3,
    Spring Annotation JAX-RS Annotation
    @RequestMapping(path = "/troopers" @Path("/troopers")
    @RequestMapping(method = RequestMethod.POST) @POST
    @RequestMapping(method = RequestMethod.GET) @GET
    @RequestMapping(method = RequestMethod.DELETE) @DELETE
    @ResponseBody N/A
    @RequestBody N/A
    @PathVariable("id") @PathParam("id")
    @RequestParam("xyz") @QueryParam('xyz")
    @RequestParam(value="xyz" @FormParam(“xyz”)
    @RequestMapping(produces = {"application/json"}) @Produces("application/json")
    @RequestMapping(consumes = {"application/json"}) @Consumes("application/json")
  13. two methods of returning a JSON response (not a view) from a Spring MVC controller
  14. I've tested the below with Spring Web MVC 4.3.5:

    
        import org.springframework.web.bind.annotation.RequestMapping;
        import org.springframework.web.bind.annotation.RequestParam;
        import org.springframework.web.bind.annotation.RequestMethod;
        import org.springframework.web.bind.annotation.ResponseBody;
    
        import org.springframework.http.ResponseEntity;
        import org.springframework.http.MediaType;
        import org.springframework.http.HttpHeaders;
        import org.springframework.http.HttpStatus;
    
        @RequestMapping(path="/example-of-method-1-of-generating-a-JSON-response", method=RequestMethod.GET)
        public ResponseEntity fooBar(final HttpServletRequest request
                             , @RequestParam(value="json", required=true) String json) {
            final HttpHeaders httpHeaders= new HttpHeaders();
            httpHeaders.setContentType(MediaType.APPLICATION_JSON);
            return new ResponseEntity(GsonHelper.toJson(new FooBar(json)), httpHeaders, HttpStatus.OK);
        }
    
        @ResponseBody
        @RequestMapping(path="/example-of-method-2-of-generating-a-JSON-response", method=RequestMethod.GET)
        public String fooBar2(final HttpServletRequest request
                             , @RequestParam(value="json", required=true) String json) {
            return GsonHelper.toJson(new FooBar(json));
        }
    
        ...
        class FooBar {
            public String echo;
            public FooBar(String echo) {
                this.echo = echo;
            }
        }