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>
@Controller
class TestController {
class Form(val a: Boolean = true)
@RequestMapping
fun handle(@ModelAttribute form: Form) {
}
}
when checkbox is unchecked, request should be:
and the value of form.a should be false, but currently it remains true.
|
String[] paramNames = (cp != null ? cp.value() : parameterNameDiscoverer.getParameterNames(ctor)); |
Affects: 5.0 RC3
Issue Links:
Referenced from: commits 496223a, 9aa369f
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:
when checkbox is unchecked, request should be:
and the value of
form.ashould befalse, but currently it remainstrue.spring-framework/spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java
Line 238 in 61cdc84
Affects: 5.0 RC3
Issue Links:
@ConstructorProperties)Referenced from: commits 496223a, 9aa369f