Maven archetype used :
mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeVersion=2.25.1 -DgroupId=fr.husta.test.jaxrs -DartifactId=jaxrs-sample-jersey -B
What is the use of certain HTTP headers ?
HTTP Header | Use | JAX-RS Annotations | Example |
---|---|---|---|
|
Used to set the preference for the content type of the response body. Can have multiple values. If unsuitable, server will send a HTTP 406. |
|
application/json,application/xml |
|
Used to precise the content type of the request body. |
|
application/json |
HTTP Header | Use | JAX-RS Annotations | Example |
---|---|---|---|
|
Used to precise the content type of the response body. No header if no content. |
Depends on |
application/json |
Up to Jersey 2.25, Java 6 and JAX-RS 2.0 (JSR-339) are required.
As of Jersey 2.26, there are important changes :
-
Requires Java 8
-
Use JAX-RS 2.1 (JSR-370)
Open a browser on http://localhost:8090/jaxrs-sample-jersey/
Or try :
curl -X GET http://localhost:8090/jaxrs-sample-jersey/webapi/myresource[http://localhost:8090/jaxrs-sample-jersey/webapi/myresource]
Generated with Asciidoctor 2.0.22