Hi All
First of all I hope this is the correct repository to post this issue, it may be more suitable for the spring-framework repository.
I was having issues with automatic form object binding, however this issue is only occurring on Spring Boot 2.3.1-RELEASE. Discovered the issue after noticing the same technique worked fine on another project under Spring Boot 2.3.0-RELEASE.
class VersionPublishForm {
Platform[] platforms; //expected to be mapped when the form is submitted
}
However the following exception is thrown:
Failed to convert property value of type java.lang.String[] to required type at.helpch.ecloud.platform.Platform[] for property platforms;
nested exception is java.lang.IllegalStateException: Cannot convert value of type java.lang.String to required type at.helpch.ecloud.platform.Platform for property platforms[0]:
no matching editors or conversion strategy found
As soon as I downgraded the version to 2.3.0-RELEASE. All worked as expected.
If required, heres also the corresponding section of the Thymeleaf template that handles this:
<div class="field">
<label class="label">Supported Platforms</label>
<article th:if="${#fields.hasErrors('platforms')}" class="message is-danger">
<div th:errors="*{platforms}" class="message-body"></div>
</article>
<div th:each="platform : ${platformList}">
<label class="checkbox">
<input th:field="*{platforms}" th:value="${platform.id}" type="checkbox"/>
<span th:text="${platform.name}"></span>
</label>
</div>
</div>
Another thing to note: The form enctype is multipart/form-data
I have an image here which shows the errors of the BindingResult.
It seems as if the value "2" (platform id) is being treated as a string, where it should be an integer.
Many Thanks
Comment From: wilkinsona
Thanks for the report, @Niall7459. This could be a Spring Framework issue as Spring Boot 2.3.1 and 2.3.0 use different Spring Framework versions. Let's see if we can figure that out here. We can then transfer the issue to Framework if needs be.
Unfortunately, it's hard to tell what's happening from the information you've provided thus far. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: john-refaat
I have reproduced this error and it was fixed when I added a custom type converter. You can check the code here: https://github.com/john-refaat/spring-boot-demo