From the course: Java EE: RESTful Service with JAX-RS 2.0
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Path parameters
From the course: Java EE: RESTful Service with JAX-RS 2.0
Path parameters
- [Narrator] So far, we have seen how to annotate resource methods with HTTP methods GET and POST, But there are more HTTP methods than just those. We have a whole list of those methods on the screen here. However, in the bookshelf application, we're only going to use GET, POST, DELETE, and PUT. We have seen that a resource method can accept two resource instances as a parameter. This resource instance is created from an HTTP body of a POST request. It is deserialized from the JSON payload of the HTTP Body, to a book instance, which can then be persisted in the persistence layer of the application. Now is a good time to talk about path parameters. So, what are path parameters? Well, they are variables that are embedded in the URI. As an example, consider the URI that you see here. It has a variable, 123456789 embedded in it and in this case, it happens to be an ISBN of a book. And what we want to do here is to retrieve it and use it. If this is a GET request, the REST API should…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Define the REST contract3m 42s
-
(Locked)
Inheritance or XML configuration3m 25s
-
(Locked)
Define the API root3m 14s
-
Create the resource entity5m 37s
-
(Locked)
Create the resource methods6m 16s
-
(Locked)
Path parameters2m 35s
-
(Locked)
Add path paramaters3m 21s
-
@Consumes and @Produces2m 7s
-
(Locked)
Add the media types4m 56s
-
(Locked)
Challenge: Add resource methods31s
-
(Locked)
Solution: Add resource methods1m 56s
-
(Locked)
-
-
-
-