In the previous example, we created mappings that depend on the end of the address. Remind the screen:
What would allow us, for example, to implement a shop with product categories? But what if we had hundreds of different categories? Create separate methods for each category? It would be more convenient to capture the category name from the address bar and pass it to the SQL query to filter the product. Let’s see:
in braces. This means that any text may appear here and is captured by @PathVariable. The @PathVariable parameter is the name of the variable we have specified in @RequestMapping. The value is assigned to variable x.
This time I defined three path variables. Spring will expect exactly three path variables. If we specify one, the call will be handled by the first method. At 2 we get an error because we do not have any method that supports exactly 2 parameters. This time I introduced this address: