Currencies are a vital part of the modern world. With the ever-increasing globalization, currencies are now in more places than ever before. This means that currency data can be access from anywhere…
Using PathVariable is very simple
This function allows you to use the value entered in url
ex.) /users/seonggil
→ return Seonggil’s UserInfo
I’ll focus on “why”
HttpServletRequest was used to get these values.
These values were obtained from url using httpServletRequest,
However, the reason for using PathVariable is clear
I’ll explain this reason now
Most RestApi writes the resource number to the URL path
like this
GET /users/1234, /users/4321
As described above, this request is mapped like /users/{userId} in Controller
Of course, using HttpServletRequest can yield the same resultsrequest.getParameter()
But, It isn’t the way the spring orientation
Because Boilerplate
Code that is reused in multiple locations with minimal change and is repeatedly similar in form
This makes maintenance difficult
Therefore, the role of the boiler plate delegate to the spring using the annotation @PathVariable
That’s what I thought about this
I don’t know if it’s right
But I think this is one of the role of the framework
I have seen a lot of people who start their careers in web development. One thing they forget and that is the main problem with max developers. They do what others do. They don’t know what they can…