본문 바로가기
Java && Spring

thymeleaf input에 default value 적용 안되는 현상

by 행복 개발자 2022. 6. 20.

이유는 정확히 모르겠지만 th:field 를 사용하는 대신에 name을 사용해야 한다. 

하지만 name 값이 단순 필드가 아니라 아래처럼 list의 필트인 경우 value가 null 넘어오는 현상이 있다. 

 

<input type="hidden" th:name="*{itemOptionGroupList[0].ordering}" value="1">

참고 : https://stackoverflow.com/questions/31542032/how-to-add-default-values-to-input-fields-in-thymeleaf

 

How to add default values to input fields in Thymeleaf

I am programming in Spring and using Thymeleaf as my view, and am trying to create a form where users can update their profile. I have a profile page which lists the user's information (first name,...

stackoverflow.com