Beware using the struts package.. several quirks of the system are not widely documented… Just ran into an issue on a project trying to put values into a bean backed with a map… easy enough? Except our keys used an index that we need to put values into xpath…
For example, we have stuff like this: property=”value(document/s25[1]/conditiontext)”
Unfortunately, looking at the BeanUtils setProperty code:
// Invoke the setter method
try {
if (index >= 0) {
PropertyUtils.setIndexedProperty(target, propName,
index, newValue);
} else if (key != null) {
PropertyUtils.setMappedProperty(target, propName,
key, newValue);
} else {
PropertyUtils.setProperty(target, propName, newValue);
}
} catch (NoSuchMethodException e) {
throw new InvocationTargetException
(e, "Cannot set " + propName);
}
You can clearly see that if a property has an index (which is a property with square braces in it) then it uses setIndexedProperty.
So if you want to use setMappedProperty and your property key has square braces… you’d better think again.









