Understanding the Initial Selection of the Radio Button for thymeleaf

Asked 1 years ago, Updated 1 years ago, 86 views

The following is written in thymeleaf, but the initial value is not selected.

<input type="radio"th:value="${item.id}"th:field="*{selectId}"checked/>

The problem seems to be using th:field (it is initially selected when th:field is removed), but if th:field is removed, the form does not have a value and cannot pass the radio button value to the server side.

What should I write in this case?

spring thymeleaf

2022-09-30 21:29

1 Answers

th:checked="${item.key=='******'}"

The initial value is selected as the one specified in ******.


2022-09-30 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.