Skip to content
Advertisement

How to fix Thymeleaf th:field unexpected error

I am new to Spring Boot and Thymeleaf. I tried to follow some example but got error as below with no any ideas…

My Spring Boot version is 2.7.1 and Java 17

entity:

JavaScript

controller:

JavaScript

view:

JavaScript

The th:field will get 500 internal error when I open this web page….

I’ve google and take a look in Thymeleaf document, but seems the th:field usage is correct.

JavaScript

Advertisement

Answer

From incomplete template code I’m asuming the error is due to the fact that you only set a taco attriubte in your controller model.addAttribute("taco", new Taco()); but call a design object in view <form method="POST" th:object="${design}"> You’d either have to change the ${design} to ${taco} or define a seperate design attirbute

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement