Append.jsp
---------------
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Append Tag Example</title>
</head>
<body>
<h1>Struts 2 Append tag example</h1>
Combine ArrayList1 and ArrayList2 into a single iterator.
<s:append id="AppendList">
<s:param value="%{list1}" />
<s:param value="%{list2}" />
</s:append>
<s:iterator value="%{#AppendList}">
<li><s:property /></li>
</s:iterator>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------------
index.jsp
-------------
<body>
<a href="AppendTag.action">Append Control Tag Example</a>
</body>
--------------------------------------------------------------------------------------------------------------------------
AppendTag.java
----------------------
package kites;
import com.opensymphony.xwork2.ActionSupport;
import java.util.*;
import org.apache.struts2.util.AppendIteratorFilter;
public class AppendTag extends ActionSupport {
private List<String> list1 = new ArrayList<String>();
private List<String> list2 = new ArrayList<String>();
public String execute() throws Exception {
list1.add("USER1");
list1.add("USER2");
list1.add("USER3");
list2.add("user1");
list2.add("user2");
list2.add("user3");
return SUCCESS;
}
public List<String> getList1() {
return list1;
}
public List<String> getList2() {
return list2;
}
}
--------------------------------------------------------------------------------------------------------------------------
struts.xml
---------------
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<package name="default" namespace="/" extends="struts-default">
<action name="AppendTag" class="kites.AppendTag">
<result name="success">/Append.jsp</result>
</action>
</package>
</struts>
--------------------------------------------------------------------------------------------------------------------------