How can I get the values of 1-20 checkboxes from the controller?
<div>
<ul>
<li th:each="poi : ${poiList}">
<label th:for="${poi.modelName}" th:text="${poi.modelName}">modelName</label>
<input type="checkbox" th:id="${poi.modelName}"
th:name="${poi.modelName}" th:checked="false"/>
</li>
</ul>
</div>
As above, there are 20 checkboxes in the form tag.
When the send button is pressed, only the checked poi among poi1~poi20 is sent as poi6=on&poi15=on
.
How should I get the value from the controller at this time?
@PostMapping("/add")
public String save(
@RequestParam String poi1,
@RequestParam String poi2
...){
// modelName=%EB%8F%84%EB%A9%B41&poi6=on&poi15=on
if( poi == null)
...
}
I wonder if there is a better way than this way.