Search code examples
spring-mvcbindingthymeleaf

Spring MVC - Thymeleaf th:action th:object


I am using Spring MVC and Thymeleaf. My template looks like this at the form tag:

<form method="post" class="from-group">
</form>

It's works, but without th:action th:object. I liked this so much (very simple), but I did not find any explanation about this.

How does it work without th:action and th:object?


Solution

  • when you click submit button it will redirect to the current page you are on if you don't include th:action. eg: if th:action="home", it will redirect you to ../home when you submit the form. th:object is sort of what kind of object you want to response. eg: an object called 'person', which it has Name, Sex, DOB, ect. You do not need to use it.