casid / jte

Secure and speedy templates for Java and Kotlin.
https://jte.gg
Apache License 2.0
737 stars 54 forks source link

Receive form data in Spring Boot POST request #318

Open Lakinator opened 6 months ago

Lakinator commented 6 months ago

I'm trying to receive the data from a form submitted as a POST request. Currently my workaround is to get the values from HttpServletRequest request and its parameter map. But i want to directly bind the returned values to a dto object like e.g. here: https://www.baeldung.com/spring-mvc-and-the-modelattribute-annotation Does binding an entity to a form work in jte?

casid commented 6 months ago

jte is a template engine and has no idea about Spring.

I don't use Spring at all, maybe the jte Spring Boot Starter covers this, but I'm not sure.

Lakinator commented 6 months ago

I currently use regular RequestParams in Spring, but e.g. JSP ha support for binding a model to form elements. Maybe this could be implemented for jte in the spring boot starter as well

tschuehly commented 6 months ago

I currently use regular RequestParams in Spring, but e.g. JSP ha support for binding a model to form elements. Maybe this could be implemented for jte in the spring boot starter as well

Would be a nice idea! Thymeleaf has th:field aswell:

which expands to:

https://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html