简体   繁体   中英

Value from th:text nested in th:action in thymeleaf

I want to use a value from car.id in the th:action. This code below redirects the user to the page of a car with id 1, so I want to replace the "1" with "${car.id}":

               <p th:text="${car.id}" />
                <form action="#" th:action="@{/cars:1}" method="get">
                    <p><input type="submit" value="car panel"  /></p>
                </form>

I tried it with:

           <form action="#" th:action="@{/cars:"${car.id}"}" method="get">

but unfortunately it does not work. How can I pass the value?

Here is how it is displayed on the site: page

Thymeleaf 的 标准 URL 语法页面上有这样的例子:

<form action="#" th:action="@{/cars:{id}(id=${car.id})}" method="get">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM