Parameters in EL methods

前端 未结 1 1111
轻奢々
轻奢々 2021-01-28 08:50

I want to use a method in JSP using EL that has a parameter. But EL doesn\'t support parameters in methods. Actually I want to show a table, which has a field that output a list

相关标签:
1条回答
  • 2021-01-28 09:34

    The support for passing method arguments and invoking non-getter methods was introduced in EL 2.2 which is part of Servlet 3.0. So your best bet is to upgrade to a Servlet 3.0 compatible container, such as Tomcat 7, Glassfish 3, JBoss AS 6 and ensure that your web.xml is declared conform Servlet 3.0 spec, so that you can do the following:

    <c:forEach var="entrant" items="${bean.entrants}">
        <tr>
            <td>${entrant.idEntrant}</td>
            <td>${bean.getGroupCode(entrant.idGroup)}</td>
            <td>${entrant.name}</td>
        </tr>
    </c:forEach>
    

    If your container doesn't support it, then your best bet is to create a custom EL function.

            <td>${some:getGroupCode(bean, entrant.idGroup)}</td>
    
    0 讨论(0)
提交回复
热议问题