How can I access a HashMap using Expression Langua

2019-03-15 02:12发布

问题:

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?

回答1:

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

${doctors[appointment.docID]} 


标签: el