Reputation: 230
I'm creating a RESTful Webservice with JAVA and netbeans. The Webservice outputs correct JSON data BUT the problem comes in when I want to read a variable I sent via GET when calling the webservice from the browser.
When I try to output the variable that I just sent with GET, the WS gives back a NULL. In addition , Glassfish server console outputs this :
Any help?
Upvotes: 3
Views: 7882
Reputation: 936
Might be the issue is because of CORS(Cross Origin ResourceSharing).Try to add CORS plugin for your browser or you can add CORS header in Response like return Response.ok(resp).header("Access-Control-Allow-Origin", "*").build();
Upvotes: 1
Reputation: 585
When using a @PathParam annotation you need to add the @Path annotation to the method declaration.
@GET
@Path("/{test}")
@Produces("application/json")
public String getJson(@PathParam("test") String test) {
return test;
}
Upvotes: 2