Skip to content

Immutable object constructor arguments not considering WebDataBinder's FIELD_MARKER_PREFIX [SPR-15871] #20426

Closed
@spring-projects-issues

Description

@spring-projects-issues

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.


String[] paramNames = (cp != null ? cp.value() : parameterNameDiscoverer.getParameterNames(ctor));


Affects: 5.0 RC3

Issue Links:

Referenced from: commits 496223a, 9aa369f

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions