[Original] Output multi-dimensional array with Iteerate

xiaoxiao2021-03-06  67

This article is slightly changed on the article "Tags of Struts".

Iterate-view.jsp:

★ 〓〓〓〓〓〓〓 ★
<% string [] TEMP = (String []) Iterate;%>

<% = Temp [0]%> | <% = Temp [1]%> | <% = Temp [2]%>

IteraTeAction.java:

Package beantest;

Import javax.servlet.http.httpservletRequest; import javax.servlet.http.httpservletResponse;

Import org.Apache.struts.Action.Act; import org.apache.struts.action.actionform; import org.apache.struts.action.actionforward; import org.apache.struts.Action.Apache.APPING;

public class IterateAction extends Action {public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {IterateBean ibean = (IterateBean) form; String [] [] temp = {{ "a1", "a2", "A3"}, {"b1", "b2", "b3"}}; ibean.setname (TEMP); return mapping.findforward ("Iterate-View");}}

IterateBean.java

Package beantest;

Import org.apache.struts.Action.actionform;

Public Class {Private String [] [] name = null; public void setname (String [] name) {this.name = name;} public string [] [] getName () {returnim. .. }

Output effect:

Http: // localhost: 8080 / mystruts / eye / item-test

★ 〓〓〓〓〓〓〓〓 ★ A1 | A2 | A3

★ 〓〓〓〓〓〓〓〓 ★ B1 | B2 | B3

It can be seen that although the Iterate tag itself is relatively simple, it is still possible to achieve some special functions.

转载请注明原文地址:https://www.9cbs.com/read-119827.html

New Post(0)