Relative Content

Tag Archive for javaspringurlthymeleafbackend

Thymeleaf th:action equal to link expression which contains a context relative URL, or another, based on condition

The context:
I’ve been developing a Proof of Concept application (for the sake of learning) with Java 17, Spring Framework, and in the front end HTML, CSS and Thymeleaf. The inventory view shows each Item object (Which has attributes like, very importantly, the Unique Identifier, price, name, discount, etc…) in my “Data Base” (ArrayList, for the sake of simplicity), along with the update button at the right side of every single Item. In case the Update button is pressed, consequently the user is redirected to a view item_form.html which posess a form with prepopulated information from the respective item the user desired to update. The way I know in the front end if such form was accessed via the inventory view it’s because the Spring Model might (or might not) contain an id key (Which is the Unique Identifier of the Item object my StoreController sent). I find hard to illustrate my idea so I’ll be showing the necessary code to reach my problem: