不懂下面struts頁面的集合是什麼時候產生的,請高手指教

lightwiter發表於2004-05-12
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<html:html xhtml="true" locale="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Select / Options examples</title>
<html:base />
<link rel="stylesheet" type="text/css" href="../../css/example.css" />
</head>
<body>
<html:link page="/jsp/options/source.jsp">
  <img src="../../images/code.gif" width="24" height="24" alt="View Source" class="icon" />
</html:link> 
<a href="../../index.jsp"><img src="../../images/return.gif" height="24" width="24" alt="Return to examples page" class="icon" /></a>
<h1>Select / Options examples</h1>
<hr noshade="noshade"/>
<p>View the HTML source to see the generated option values.</p>
<html:form action="/processOptions">
	<h2>1. Simple select tags</h2>
	<table width="100%" border="0" cellspacing="10" cellpadding="0">
		<tr valign="top">
			<td width="33%">
			<p>Single select, size=&quot;1&quot; (drop down list)</p>
			<p><html:select property="fruit1">
				<html:option value="Strawberry">Strawberry</html:option>
				<html:option value="Apple">Apple</html:option>
				<html:option value="Orange">Orange</html:option>
				<html:option value="Pear">Pear</html:option>
				<html:option value="Mango">Mango</html:option>
				<html:option value="Banana">Banana</html:option>
				<html:option value="Pineapple">Pineapple</html:option>
			</html:select></p>
			</td>
			<td width="33%">
			<p>Single select, size=&quot;4&quot;</p>
			<p><html:select property="fruit2" size="4">
				<html:option value="Strawberry">Strawberry</html:option>
				<html:option value="Apple">Apple</html:option>
				<html:option value="Orange">Orange</html:option>
				<html:option value="Pear">Pear</html:option>
				<html:option value="Mango">Mango</html:option>
				<html:option value="Banana">Banana</html:option>
				<html:option value="Pineapple">Pineapple</html:option>
			</html:select></p>
			</td>
			<td width="33%">
			<p>Multi-select, size=&quot;7&quot;</p>
			<p><html:select property="fruit3" size="7" multiple="true">
				<html:option value="Strawberry">Strawberry</html:option>
				<html:option value="Apple">Apple</html:option>
				<html:option value="Orange">Orange</html:option>
				<html:option value="Pear">Pear</html:option>
				<html:option value="Mango">Mango</html:option>
				<html:option value="Banana">Banana</html:option>
				<html:option value="Pineapple">Pineapple</html:option>
			</html:select></p>
			</td>
		</tr>
	</table>
	<h2>2. Populating options from arrays and collections</h2>
	<table width="100%" border="0" cellspacing="10" cellpadding="0">
		<tr>
			<td width="33%" valign="top">
			<p>Option values and labels populated from the same array:</p>
			<p><html:select property="color1" size="7">
				<html:options name="colors" />
				</html:select>
			</p>
			</td>
			<td width="33%" valign="top">
			<p>Option values and labels populated from different arrays:</p>
			<p><html:select property="color2" size="7">
				<html:options name="colorCodes" labelName="colors" />
			</html:select></p>
			</td>
			<td width="33%" valign="top">
			<p>Option values populated from an array and labels populated from a
			collection:</p>
			<p><html:select property="color3" size="7">
				<html:options name="colorCodes" labelName="colorCollection" />
			</html:select></p>

			</td>
		</tr>
	</table>
	<h2>3. Populating options from a Collection of LabelValueBeans</h2>
	<table width="100%" border="0" cellspacing="10" cellpadding="0">
		<tr valign="top">
			<td width="33%">
			<p>Options populated from a Collection of LabelValueBeans, using
			<html:options>:</p>
			<p><html:select property="day1" size="7">
				<html:options collection="days" property="value"
					labelProperty="label" />
			</html:select></p>
			</td>
			<td width="33%">
			<p>Options populated from a Collection of LabelValueBeans, using
			<html:optionsCollection>:</p>
			<p><html:select property="day2" size="7">
				<html:optionsCollection name="days" />
			</html:select></p>
			</td>
			<td width="33%">&nbsp;</td>
		</tr>
	</table>
	<h2>4. Populating options from a Collection of custom beans</h2>
	<table width="100%" border="0" cellspacing="10" cellpadding="0">
		<tr valign="top">
			<td width="33%">
			<p>Options populated from a Collection of BookBeans, using<br />
			<html:options>:</p>
			<p><html:select property="book1" size="7">
				<html:options collection="books" property="isbn"
					labelProperty="title" />
			</html:select></p>
			</td>
			<td width="33%">
			<p>Options populated from a Collection of BookBeans, using<br />
			<html:optionsCollection>:</p>
			<p><html:select property="book2" size="7">
				<html:optionsCollection name="books" value="isbn" label="title" />
			</html:select></p>
			</td>
			<td width="33%">&nbsp;</td>
		</tr>
	</table>
	<h2>4. Populating options from a Map</h2>
	<table width="100%" border="0" cellspacing="10" cellpadding="0">
		<tr valign="top">
			<td width="33%">
			<p>Options populated from a Map, using <br />
			<html:options>:</p>
			<p><html:select property="animal1" size="5">
				<html:options collection="animals" property="key"
					labelProperty="value" />
			</html:select></p>
			</td>
			<td width="33%">
			<p>Options populated from a Map, using <br />
			<html:optionsCollection>:</p>
			<p><html:select property="animal2" size="5">
				<html:optionsCollection name="animals" value="key" label="value" />
			</html:select></p>
			</td>
			<td width="33%">&nbsp;</td>
		</tr>
	</table>

	<hr />
	<p><html:submit />
	   <html:cancel />
	   <html:reset />
	</p>
</html:form>

</body>
</html:html>
<p class="indent">

這個裡面的colors集合從哪裡來的
還有colorCodes集合
以及下面的animals和books集合。壓根就沒有看到這兩個集合在哪裡建立的。

http://www.ninsky.com/struts/download/struts-examples.zip

相關文章