Is there a way to Spring bind values in a map?
For instance, I have a Map<String,String>
and I want to spring bind specific values in it.
The user will type something into a input element, and the value of that input element will get bound to the value associated with a specific key in the map.
Yes, you can do it with [...]
syntax. The Map
itself, however, should be a property of the command object:
public class Form {
private Map<String, String> values = ...;
...
}
Then you submit a form with the input field named values['foo']
, i.e. with Spring form tags it would be a path
:
<form:input path = "values['foo']" />
or name
in plain HTML:
<input name = "values['foo']" type = "text" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With