Closed
Description
Jean opened SPR-15871 and commented
Unchecked checkbox value should be recognized via WebDataBinder#fieldMarkerPrefix
.
However when creating attribute, only constructor parameter names used, so field marker is not applied.
When this html form submit:
<form>
<input type="checkbox" name="a" value="true">
<input type="hidden" name="_a" value="on">
</form>
- kotlin code
@Controller
class TestController {
class Form(val a: Boolean = true)
@RequestMapping
fun handle(@ModelAttribute form: Form) {
}
}
when checkbox is unchecked, request should be:
?_a=on
and the value of form.a
should be false
, but currently it remains true
.
Affects: 5.0 RC3
Issue Links:
- Data binding with immutable objects (Kotlin / Lombok / @ConstructorProperties) [SPR-15199] #19763 Data binding with immutable objects (Kotlin / Lombok /
@ConstructorProperties
) - BindingResult support for constructor argument mismatch on immutable data object [SPR-15542] #20101 BindingResult support for constructor argument mismatch on immutable data object
- Revisit handling of missing fields (without default values) for immutable data classes [SPR-15877] #20432 Revisit handling of missing fields (without default values) for immutable data classes