How can I access a HashMap using Expression Language

el
Marcos Roriz Junior picture Marcos Roriz Junior · Dec 12, 2010 · Viewed 16.3k times · Source

I'm having some problems on manipulating data in EL / JSP.

I have two variables in my Action (I'm using Struts2 btw) they are:

private List<Appointment> appointment;
private Map<Integer, String> doctors;

Appointment has the attribute docID and the doctors list uses this to identify the Doctor full name; I want in my JSP to get the doctor full name. That is, I want this:

${doctors[${appointment.docID}]} 

However this dont work. Any idean on how to get this working?

Answer

Bozho picture Bozho · Dec 12, 2010

You don't need to open another EL-expression. Just remove the inner-one:

${doctors[appointment.docID]}