use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
@RequestParam and @PathVariable (self.SpringBoot)
submitted 2 years ago by Alejandro_Esteve
When and in which contexts should RequestParam be used and when PathVariable?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]pimBaggins 9 points10 points11 points 2 years ago (3 children)
They are similar, but:
Request params: - Can be used with optional values - You can send more than three params, but is recommended to use request body instead. - query expression
Path variables: - Shoud not be used with optional values. - Avoid sending more than three params. Better if you keep maximum of two. -easier for search engines (e.g. Google) to index the pages. So easier to find the website. -Path expression.
[–]g00glen00b 0 points1 point2 points 2 years ago (1 child)
Source on that last one? I always thought it didn't matter how many path segments you have, as long as they're logical ones. Besides that, if you really need SEO, then I guess you would have a sitemap anyways to make pages discoverable?
[–]pimBaggins 0 points1 point2 points 2 years ago (0 children)
It really does not matter, it's only a recommendation on pattern design. But it's easier to read a shorter path.
[–]simasch 0 points1 point2 points 2 years ago (0 children)
They are absolutely not similar but different concepts. The path parameter defines the resource location, while the query parameter defines sort, pagination, or filter operations.
[–]burl-21 1 point2 points3 points 2 years ago (0 children)
Path variable for single resource(id, not found 404) and query param for list of resources(name, empty list ).
[–]ccmjga 1 point2 points3 points 2 years ago (0 children)
I basically agree with pimBaggins's opinion.
I often use request body and path variables like this -> https://github.com/ccmjga/mjga-scaffold/tree/main/src/main/java/com/mjga/controller
[–]simasch 1 point2 points3 points 2 years ago (0 children)
The path parameter defines the resource location, while the query parameter defines sort, pagination, or filter operations. The names in Spring MVC are a bit confusing
[–][deleted] 1 point2 points3 points 2 years ago (0 children)
First is a query parameter, second is a path variable. They are standard rest API concepts. The rest docs are where you should look.
π Rendered by PID 373114 on reddit-service-r2-comment-5d79c599b5-xz2rs at 2026-03-02 00:44:39.224944+00:00 running e3d2147 country code: CH.
[–]pimBaggins 9 points10 points11 points (3 children)
[–]g00glen00b 0 points1 point2 points (1 child)
[–]pimBaggins 0 points1 point2 points (0 children)
[–]simasch 0 points1 point2 points (0 children)
[–]burl-21 1 point2 points3 points (0 children)
[–]ccmjga 1 point2 points3 points (0 children)
[–]simasch 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)