This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts 2 parameter mapping issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 parameter mapping issue" Watch "Struts 2 parameter mapping issue" New topic
Author

Struts 2 parameter mapping issue

Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
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

Joined: Aug 01, 2007
Posts: 485

Let us know what you are doing? What you are type of field being populated?


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
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

Joined: May 18, 2012
Posts: 1
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2 parameter mapping issue
 
Similar Threads
Best way to figure out overlapping of strings
IllegalArgumentException: more than 10 parameters
Session object doubt
question on "immutable" strings
StringBuffer