正在从 JSP 页面中删除 Java 代码

Removing Java code from JSP page

我负责此 jsp、servlet 和 struts。 (Jsp 版本 2.0,servlet 2.4,struts 1)。 一个 "for" 循环在另一个循环中。

...
<%
    String[] profileNames = { "Page", "Report", "XML API" };
    for (String profileName : profileNames) {

        LRUCache profile = ObjectStore.getStore(profileName + " Profile");
        pageContext.setAttribute("profile", profile);
        pageContext.setAttribute("profileName", profileName);
%>

<table class="sortable" id="<%=profileName%>">
    <tr class=title>
        <th class=contentTable>description</th>
        <th class=contentTable>qty</th>
    </tr>
    <c:forEach var="profile" items="${profileItems}">
        <tr>
            <td>${profile.object.description}</td>
            <td>${profile.object.qty}</td>
        </tr>
    </c:forEach>
</table>
<%
    }
%>

我需要没有 java 代码的 jsp 页面。如何实施?

感谢您的帮助!

发送您当前在 pageContext 中 "putting" 的相同属性:profileprofileName 在 Servlet 上(或您正在使用的任何其他类似技术来处理requests/responses).

类似于:request.setAttribute("key", value); 在 Servlet class 上。

更新: 我在这里进行了快速搜索,您可能真的想看看这个 one.