Access an object in JSP

This question already has an answer here:

  • How to avoid Java code in JSP files? 28 answers

  • Please see @BalusC's excellent answer on the subject:

    https://stackoverflow.com/a/3180202/2112089

    Basically, accessing POJOs is discouraged because it leads to unmaintainable code. It is much better to use JSTL and Expression Language (EL).

    To do that, here's his example:

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    ...
    <table>
        <c:forEach items="${products}" var="product">
            <tr>
                <td>${product.name}</td>
                <td>${product.description}</td>
                <td>${product.price}</td>
            </tr>
        </c:forEach>
    </table>
    

    The rest of @BalusC's series on JSP:

    https://stackoverflow.com/a/2097732/2112089

    https://stackoverflow.com/a/3106909/2112089

    https://stackoverflow.com/a/5003701/2112089

    https://stackoverflow.com/a/3542297/2112089

    链接地址: http://www.djcxy.com/p/76606.html

    上一篇: 如何将scriptlet转换为jstl标签

    下一篇: 在JSP中访问一个对象