Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete or put methods in thymeleaf

I would like to call @RequestMapping(value = "", method = RequestMethod.DELETE) in spring from thymeleaf form.

Is there any possibility to call delete or put request mapping methods from thymeleaf?

please give your suggestion on this.

like image 479
user3128455 Avatar asked Jun 17 '14 05:06

user3128455


People also ask

Is Thymeleaf better than angular?

The most important difference is reusability of back-end services. when you use thymeleaf, you are returning string fragments/pages into client side, while if you use angular, you can return objects (json response) into client side, so that can be used by different clients (web, mobile, etc).

Is Thymeleaf better than JSP?

Thymeleaf is way better in my opinion because it have good underlying priciples and exploits natural behaviour of browsers. Jsp makes html hard to read, it becomes weird mixture of html and java code which makes a lot of problems in comunication between designer - developer.

How do I add if condition in Thymeleaf?

In some situations, you want a certain snippet of the Thymeleaf Template to appear in the result if a certain condition is evaluated as true. To do this you can use the attribute th:if. Note: In Thymeleaf, A variable or an expression is evaluated as false if its value is null, false, 0, "false", "off", "no".

Do companies use Thymeleaf?

Around the world in 2022, over 1859 companies have started using Thymeleaf as JavaScript MVC Framework tool.


1 Answers

You could use th:method for this:

<form th:object="${commandObject}" th:action="@{/urlToCall}" th:method="delete">

This will generate a hidden input element, which will be picked up by Spring MVC:

<input type="hidden" name="_method" value="delete">
like image 113
marcok Avatar answered Oct 03 '22 14:10

marcok