Introduction

Thymeleaf is a templating (server-side rendering) engine used by many Java software engineers within Spring-based web applications. An important feature of any web application is the support for dynamic URLs and path variables within those URLs.

Most REST APIs extensively use path variables to specify the IDs of elements they’re performing operations on. For instance, a typical example would be:

https://www.somewebsite.com/viewPost/path-variables-with-spring-boot
## OR
https://www.somewebsite.com/viewProduct/5

In both of these cases, we’re trying to find a resource denoted by a certain identifier. In the first case, we’re identifying a resource by its title - path-variables-with-spring-boot, while in the second, we’re identifying it through an incremental ID counter - 5.

Note: When using predictable path variables, such as an incremental counter, beware of security concerns. First of all - these are easily scrapable, but most important than anything, without proper validation - someone might figure out that /deleteProduct/5 deletes entries from the database, and decide to drop most of the entities stored within it

#java #spring boot #spring #thymeleaf path variables with spring boot #thymeleaf path

Thymeleaf Path Variables with Spring Boot
2.60 GEEK