How do I capture a variable of a href in thymeleaf Spring?

0

It turns out that when running my application, the spring boot does not capture the variable, and it shows me an error 404:

  

There was an unexpected error (type = Not Found, status = 404).   No message available

Code:

 @RequestMapping( value = "/delete/{id}", method = RequestMethod.GET)
    public String deleteAll(@PathVariable("id") int va){
        System.out.println(va);
        return "redirect:/show";
    }

html with thymeleaf:

<table class="table table-condensed table-bordered">
    <th>
        <tr>
            <td>Order id</td>
            <td>Customer id</td>
            <td>Product</td>
            <td>Action</td>
         </tr>
     </th>
     <th:block th:each="list : ${lists}">
         <tr>
            <td th:text="${list.orderId}">...</td>
            <td th:text="${list.customer.name}">...</td>
            <td th:text="${list.product}">...</td>
            <td>

                <a th:href="@{/delete/(id=${list.orderId})}">Delete</a>...
            </td>
         </tr>
      </th:block> 
    </table>
    
asked by Cristian Galindo 09.01.2018 в 23:05
source

1 answer

0

Try concatenating the th: href in the following way:

th:href="@{/delete/} + ${list.orderId}"
    
answered by 10.01.2018 / 07:10
source