Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 parameter mapping issue

 
Don Blodgett
Ranch Hand
Posts: 61
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem populating a parameter to a Map<String, String>. I have the following parameter that does not get placed in the newValue within my model which has a getter and setter for newValue:

newValue['1234-5'] = ABCDE

But if I have the following it works:

newValue['12345'] = ABCDE

I am wondering why it does not populate the map when I have a dash?
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let us know what you are doing? What you are type of field being populated?
 
Don Blodgett
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following classes, MyModel is set into MyAction through the use of Spring:





When I pass as a parameter the following, the newValues Map in MyModel is null:



If I pass the parameter as the following, the newValues Map in MyModel has the key/value pair of 12345=ABCDE:



The only difference is that in the non-working parameter I have a dash in the key and the working parameter I do not have the dash in the key.

The dash is important to have as it is part of the unique Id for this process.

I have found another way of doing this by creating a list of custom model classes that has a key and value field, but I am still wondering why a Map will not work for this case.
 
Nemo Stein
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the exactly same problem! (map with dashes in the key)

Do you have any workaround or solution?


EDIT: I solved myself, replacing the dashes ("-") to underscores ("_") in JSP, than, replaced back in the controller.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic