Back Forum Reply New

How to connect spring:bind to a non-string map key?

hi!

In my project I have to access a map. The map key is a custom java POJO with an id string field and java.lang.Integer for the map value.

I'd like to bind it on my JstlView. See the example below for the problem. Group is my custom POJO as map-key.
The following code works well, and prints the map entry's value:

Code:
lt;c:forEach var=quot;groupquot; items=quot;${groups}quot;gt;
lt;cut value=quot;${commandObject.mapAttribute[group]}quot;/gt;
lt;/c:forEachgt;
But it does not bind this way:

Code:
lt;c:forEach var=quot;groupquot; items=quot;${groups}quot;gt;
lt;spring:bind path=quot;commandObject.mapAttribute[${group}]quot;gt;lt;/spring:bindgt;
lt;/c:forEachgt;
However, I know if the map key is a string I can bind it like this:

Code:
lt;c:forEach var=quot;stringIdquot; items=quot;${groupStringIds}quot;gt;
lt;spring:bind path=quot;commandObject.mapAttribute['${stringId}']quot;gt;lt;/spring:bindgt;
lt;/c:forEachgt;
Is there a solution to bind to a non-string map key in SpringMVC?

Thanks for help.

--
Thomas
¥
Back Forum Reply New