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.
Add path paramaters
From the course: Java EE: RESTful Service with JAX-RS 2.0
Add path paramaters
- [Instructor] Okay, so let's create a method that retrieves a book based on this ISBN. I'll call this method getBookByIsbn, and the path variable is going to be called ISBN. So, it's going to be a public method, it's going to return a response object, as before. And we're going to simply call it getBookByIsbn. And we're gonna have a path variable which we are going to be making final. We're gonna use the path parameter here, and we're going to use the variable ISBN. And I'll show you how to program that part in a moment. And we're gonna parse that through as a string to a variable, I'm going to call it ISBN, okay. Now that I set the path annotation and parsed the regular expression, we're gonna add path and we're simply going to parse it at a regular expression. As you can note here, the name of the variable is ISBN, and the regular expression follows the name of the variable. And the variable ISBN matches with the variable name in the path parameter. And don't forget, we need to…
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)
-
-
-
-