Skip to content

Annotation-driven formatting does not work when BindTag's path contains a reference to an array/list element [SPR-6710] #11376

@spring-projects-issues

Description

@spring-projects-issues

Bjarte Andre Eide opened SPR-6710 and commented

In the following jsp-example, Spring does not discover the formatting annotations attached to the discount-property.

<spring:bind path="orderItems[0].discount">
   ${status.displayValue}
</spring:bind>

The problem can be traced back to the two following lines in org.springframework.beans.BeanWrapperImpl

358 String canonicalName = PropertyAccessorUtils.getPropertyName(propertyName);
359 PropertyDescriptor pd = getPropertyDescriptorInternal(canonicalName);

If line 358 is replaced with 'canonicalName = propertyName', everything works fine. However I do not know if this will break other code if line 358 is removed/replaced.

The following stacktrace shows the entry for how the jsp is accessing the BeanWrapperImpl:

org.springframework.beans.BeanWrapperImpl.getPropertyTypeDescriptor(BeanWrapperImpl.java:358)
org.springframework.validation.AbstractPropertyBindingResult.findEditor(AbstractPropertyBindingResult.java:154)
org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:125)
org.springframework.web.servlet.tags.BindTag.doStartTagInternal(BindTag.java:119)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:78)

Attached zip-file contains some tests that fails when one of the path-element is a list/array


Affects: 3.0 GA

Attachments:

Referenced from: commits 081d81e, 5abd3b9

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions