0

I've seen a lot of answers about how to send PUT/DELETE/PATCH HTTP requests with thymeleaf, and it's by using th:method = "the_specific_method", but i haven't found the thymeleaf specification about that. Can anyone help showing me where is it?

Thanks in advance.

I've tried to google for the answer, but no luck.

seRRaloR
  • 1
  • 1

1 Answers1

1

th:method isn't special to Thymeleaf -- it's just like any other plain old attribute which will output the result of an expression to the method attribute. It doesn't do (or care about) anything else. You can put any string and/or string expression into it, and Thymeleaf will happily output it.

th:method="${'the_specific_method'}"

will output

method="the_specific_method"

without regards to whether or not it's valid. If you want to learn about the method attribute, you just need to learn about how method works in plain old regular html and how browsers (and/or Spring) work with it.

Metroids
  • 18,999
  • 4
  • 41
  • 52
  • But, as far as I know, in plain old regular html, only GET and PUT methods are valid... Am I wrong? And, on the other hand, while searching for this, I've come to answers like https://stackoverflow.com/a/24753505/11315401 that means translation is not so simple, what I'm missing? – seRRaloR Feb 08 '23 at 07:22
  • No, that is correct, `GET` and `POST` are the only valid methods. There is no translation in Thymeleaf. Thymeleaf doesn't care what you put in `th:method` -- the answers you've linked to are using a *Spring* filter to fake different methods by modifying the output of certain properties -- and while Thymeleaf gives support for hooking into their tag library, additional `th:method` logic isn't something specifically built into Thymeleaf. If you want to learn about that, you need to learn about the HiddenHttpMethodFilter and not `th:method`. – Metroids Feb 08 '23 at 15:53