Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple requestmapping value with path variables from thymeleaf

I have to send two data from thymeleaf to controller like this in a th:href:

<table id="itemTable" class="deneme">
    <tbody>
    <tr th:each="item : ${list.items}">
        <td>
            <p th:text="${item.content}"/>
            <a th:href="@{/deleteItem/{listId}(listId=${list.id})/{itemId}(itemId=${item.id})}">
                <span>Delet‌​e</span>
            </a>
        </td>
    </tr>
    </tbody>
</table>

The controller is:

@RequestMapping("/deleteItem/{listId}/{itemId}")
public String deleteItem(Model model, @PathVariable(value = "listId") Integer listId, @PathVariable(value = "itemId") int itemId) {
    ...
    return "list";
}

itemId is coming with the true value but listId is coming as {listId}(listId=${toDoList.id})

What is the problem exactly? Please help me!

like image 969
Utku Soytaş Avatar asked Oct 24 '25 16:10

Utku Soytaş


1 Answers

The syntax for multiple parameters looks like this:

<a th:href="@{/deleteItem/{listId}/{itemId}(listId=${list.id},itemId=${item.id})}"><span>Delet‌​e</span></a>
like image 184
Metroids Avatar answered Oct 26 '25 06:10

Metroids



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!