How to access an arraylist element in jsp when index is a variable?

im accessing an element in an arraylist. The problem arises because the index of the required element is a variable. can anyone help me?

eg <td><c:out value="${PARENT_MODULE[module.moduleId]}"> </c:out></td>

here module.moduleId is a variable.

I've already tried

<c:out value="${PARENT_MODULE[${module.moduleId}]}">

however, this gives an error.

org.apache.jasper.JasperException: /WEB-INF/jsp/showModules.jsp (40,20) "$ {PARENT_MODULE [$ {module.moduleId}]}" contains invalid expressions: javax.el.ELException: error analysis: $ {PARENT_MODULE [$ {module.moduleId}]}

thank

+5
source share
2 answers

, PARENT_MODULE , modules , module , moduleId

:

< c:out value="${PARENT_MODULE[num].moduleId}"/>

num - . PARENT_MODULE[num] module num " . , , moduleId.

+1

module.moduleId EL-, . ${}.

<c:out value="${PARENT_MODULE[module.moduleId]}"> .

+5

All Articles