我使用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
中“放置”的相同属性:Servlet 上的 profile
和 profileName
(或任何其他类似技术)您用于处理请求/响应)。
类似:Servlet 类上的 request.setAttribute("key", value);
。
更新:我在这里进行了快速搜索,您可能真的想看看这个 one .
关于java - 从 JSP 页面中删除 Java 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29243151/