0

I have a property in jsp like the following

   <html:text property="sequenceNumbersMap[0]"  styleId="sequenceNumbersMap[0]" value="0"/>
   <html:text property="sequenceNumbersMap[1]"  styleId="sequenceNumbersMap[1]" value="1"/>
   <html:text property="sequenceNumbersMap[2]"  styleId="sequenceNumbersMap[2]" value="2"/>
   <html:text property="sequenceNumbersMap[3]"  styleId="sequenceNumbersMap[3]" value="3"/>

and ActionForm has the property like

Map sequenceNumbersMap;

and getter/setter

public Map<Integer, Integer> getSequenceNumbersMap() {
        return sequenceNumbersMap;
    }

    public void setSequenceNumbersMap(Map<Integer, Integer> sequenceNumbersMap) {
        this.sequenceNumbersMap = sequenceNumbersMap;
    }

but when i try to submit the jsp i get the following exception :

java.lang.IllegalArgumentException: Property 'sequenceNumbersMap' is not indexed

would someone help me to fix this issue?

Thanks

Joe
  • 4,460
  • 19
  • 60
  • 106

2 Answers2

1

A map is not ordered so sequenceNumbersMap[i] does not mean anything. If you mean to get the value mapped to i rather than getting the i-th item in the map (which has no sense again), you can do it with sequenceNumbersMap.get(i).

Gaël J
  • 11,274
  • 4
  • 17
  • 32
0

You must either iterate through a map differently: How to loop through a HashMap in JSP?

Or use a different kind of data structure for sequence numbers (indexed, as it was pointed in the exception, e.g. java.util.List).

Community
  • 1
  • 1
dpavkov
  • 31
  • 3