﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-无所惧，无所悔,为梦想执着的拼搏-文章分类-struts标签</title><link>http://www.blogjava.net/DreamFight/category/37677.html</link><description /><language>zh-cn</language><lastBuildDate>Sun, 15 Feb 2009 11:03:41 GMT</lastBuildDate><pubDate>Sun, 15 Feb 2009 11:03:41 GMT</pubDate><ttl>60</ttl><item><title>Struts标签库详解 (2)</title><link>http://www.blogjava.net/DreamFight/articles/254757.html</link><dc:creator>DreamFight</dc:creator><author>DreamFight</author><pubDate>Sun, 15 Feb 2009 07:30:00 GMT</pubDate><guid>http://www.blogjava.net/DreamFight/articles/254757.html</guid><wfw:comment>http://www.blogjava.net/DreamFight/comments/254757.html</wfw:comment><comments>http://www.blogjava.net/DreamFight/articles/254757.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/DreamFight/comments/commentRss/254757.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/DreamFight/services/trackbacks/254757.html</trackback:ping><description><![CDATA[<div align="left"><strong><span style="font-size: 9pt; color: black">遗补</span></strong><span style="font-size: 9pt; color: black">：</span><span style="font-size: 9pt; color: black">1.)&lt;html:link&gt;</span><span style="font-size: 9pt; color: black">标签</span></div>
<div align="left"><span style="font-size: 9pt; color: black">forward</span><span style="font-size: 9pt; color: black">属性：链接到一个</span><span style="font-size: 9pt; color: black">global forward</span><span style="font-size: 9pt; color: black">上；</span><span style="font-size: 9pt; color: black">action</span><span style="font-size: 9pt; color: black">属性：链接到一个</span><span style="font-size: 9pt; color: black">action mapping</span><span style="font-size: 9pt; color: black">上；</span><span style="font-size: 9pt; color: black"><br />
href</span><span style="font-size: 9pt; color: black">属性：这个链接会转发给控制器，由控制器做决定；</span><span style="font-size: 9pt; color: black">page</span><span style="font-size: 9pt; color: black">属性：一个相对的链接。</span><span style="font-size: 9pt; color: black"><br />
<br />
</span><span style="font-size: 9pt; color: black">用</span><span style="font-size: 9pt; color: black">page</span><span style="font-size: 9pt; color: black">属性链接到</span><span style="font-size: 9pt; color: black">action</span><span style="font-size: 9pt; color: black">上：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 461.2pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="615" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 459.8pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="613">
            <div align="left"><span style="font-size: 9pt">&nbsp;&nbsp; &lt;html:link page="/html-link.do"&gt;<br />
            &nbsp;&nbsp; Linking with the page attribute.<br />
            &lt;/html:link&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt; color: black">注意，上面的代码中你不必指定</span><span style="font-size: 9pt; color: black">web</span><span style="font-size: 9pt; color: black">的关联。相反的，如果你使用</span><span style="font-size: 9pt; color: black">href</span><span style="font-size: 9pt; color: black">属性，你就必须像下面所示指出</span><span style="font-size: 9pt; color: black">web</span><span style="font-size: 9pt; color: black">的关联</span><span style="font-size: 9pt; color: black">(</span><span style="font-size: 9pt; color: black">这里的关联就是</span><span style="font-size: 9pt; color: black">struts-exercise)</span><span style="font-size: 9pt; color: black">：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 461.2pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="615" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 459.8pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="613">
            <div align="left"><span style="font-size: 9pt">&lt;html:link href="/struts-exercise-taglib/html-link.do"&gt;<br />
            &nbsp;&nbsp; Using Href<br />
            &lt;/html:link&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt; color: black">很明显，当你在相同的</span><span style="font-size: 9pt; color: black">web</span><span style="font-size: 9pt; color: black">应用程序中做链接是，它比</span><span style="font-size: 9pt; color: black">page</span><span style="font-size: 9pt; color: black">属性更加好。你也能用</span><span style="font-size: 9pt; color: black">href</span><span style="font-size: 9pt; color: black">在不同的服务器上创建链接：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 461.2pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="615" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 459.8pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="613">
            <div align="left"><span style="font-size: 9pt">&lt;html:link href="<a href="http://otherserver/strutsTut/html-link.do"><font color="#0000ff">http://otherserver/strutsTut/html-link.do</font></a>"&gt;<br />
            Using Href<br />
            &lt;/html:link&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt; color: black">另一种链接到</span><span style="font-size: 9pt; color: black">html-link.do</span><span style="font-size: 9pt; color: black">的方法是用</span><span style="font-size: 9pt; color: black">action</span><span style="font-size: 9pt; color: black">属性：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 461.2pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="615" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 459.8pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="613">
            <div align="left"><span style="font-size: 9pt">&lt;html:link action="/html-link"&gt;<br />
            Using Action attribute<br />
            &lt;/html:link&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt; color: black">你也可以以硬编码的方式使用参数：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 461.2pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="615" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 459.8pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="613">
            <div align="left"><span style="font-size: 9pt">&lt;html:link page="/htmllink.do?doubleProp=3.3&amp;amp;longProp=32"&gt;<br />
            &nbsp;&nbsp; Double and long via hard coded changes<br />
            &lt;/html:link&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt; color: black">或者使用</span><span style="font-size: 9pt; color: black">paramId, paramName, and paramProperty</span><span style="font-size: 9pt; color: black">属性：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 461.2pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="615" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 459.8pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="613">
            <div align="left"><span style="font-size: 9pt">&lt;html:link page="/html-link.do" paramId="booleanProperty" paramName="testbean" <br />
            &nbsp;&nbsp; paramProperty="nested.booleanProperty"&gt;<br />
            &nbsp;&nbsp; Boolean via paramId, paramName, and paramValue<br />
            &lt;/html:link&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt; color: black">解析后的代码：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 461.2pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="615" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 459.8pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="613">
            <div align="left"><span style="font-size: 9pt">&lt;a href="/struts-exercise-taglib/html-link.do?booleanProperty=false"&gt;<br />
            &nbsp;&nbsp;&nbsp; Boolean via paramId, paramName, and paramValue<br />
            &lt;/a&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt; color: black">另外，还能使用带</span><span style="font-size: 9pt; color: black">name</span><span style="font-size: 9pt; color: black">属性的</span><span style="font-size: 9pt; color: black">Map</span><span style="font-size: 9pt; color: black">来实现传递多个参数：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 461.2pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="615" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 459.8pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="613">
            <div align="left"><span style="font-size: 9pt">&lt;%<br />
            java.util.HashMap newValues = new java.util.HashMap();<br />
            newValues.put("floatProperty", new Float(444.0));<br />
            newValues.put("intProperty", new Integer(555));<br />
            newValues.put("stringArray", new String[]<br />
            { "Value 1", "Value 2", "Value 3" });<br />
            pageContext.setAttribute("newValues", newValues);<br />
            %&gt;<br />
            ...<br />
            &lt;html:link action="/html-link" name="newValues"&gt;<br />
            &nbsp;&nbsp;&nbsp; Float, int, and stringArray via name (Map)<br />
            &lt;/html:link&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt; color: black">你也能够链接到</span><span style="font-size: 9pt; color: black">Map</span><span style="font-size: 9pt; color: black">类型的</span><span style="font-size: 9pt; color: black">action</span><span style="font-size: 9pt; color: black">上，上面的代码解析后的结果：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">&lt;html:messages property="property2" message="true" id="msg" header="messages.header" footer="messages.footer"&gt;<br />
            &lt;tr&gt;&lt;td&gt;&lt;%= pageContext.getAttribute("msg") %&gt;&lt;/td&gt;&lt;/tr&gt;<br />
            &lt;/html:messages&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"><span style="font-size: 9pt; color: black">2.) select</span><span style="font-size: 9pt; color: black">和</span><span style="font-size: 9pt; color: black">option</span><span style="font-size: 9pt; color: black">标签</span><span style="font-size: 9pt; color: black"><br />
<strong>&lt;html:select&gt; </strong></span><span style="font-size: 9pt; color: black">的属性：</span><span style="font-size: 9pt; color: black">property</span><span style="font-size: 9pt; color: black">－与</span><span style="font-size: 9pt; color: black">ActionForm</span><span style="font-size: 9pt; color: black">中的某个属性对应；</span><span style="font-size: 9pt; color: black">size</span><span style="font-size: 9pt; color: black">－显示</span><span style="font-size: 9pt; color: black">option</span><span style="font-size: 9pt; color: black">的数目；</span><span style="font-size: 9pt; color: black">multiple</span><span style="font-size: 9pt; color: black">－默认为</span><span style="font-size: 9pt; color: black">fales</span><span style="font-size: 9pt; color: black">，表示不能多选，当设定为</span><span style="font-size: 9pt; color: black">true</span><span style="font-size: 9pt; color: black">时，</span><span style="font-size: 9pt; color: black">property</span><span style="font-size: 9pt; color: black">对应的</span><span style="font-size: 9pt; color: black">ActionForm</span><span style="font-size: 9pt; color: black">的属性必须为数组。</span><span style="font-size: 9pt; color: black"><br />
&lt;html:select property="name" size=6 multiple="true"&gt;<br />
<strong>&lt;html:option&gt;</strong></span><span style="font-size: 9pt; color: black">的属性：</span><span style="font-size: 9pt; color: black">key</span><span style="font-size: 9pt; color: black">、</span><span style="font-size: 9pt; color: black">local</span><span style="font-size: 9pt; color: black">、</span><span style="font-size: 9pt; color: black">bundle</span><span style="font-size: 9pt; color: black">－指定</span><span style="font-size: 9pt; color: black">Resource Bundle</span><span style="font-size: 9pt; color: black">中的内容。</span><span style="font-size: 9pt; color: black"><br />
</span><span style="font-size: 9pt; color: black">例如</span><span style="font-size: 9pt; color: black"> &lt;html:option value="color1"&gt;Orange&lt;/html:option&gt;<br />
&lt;html:option value="color1" bundle="htmlselect.Colors" key="htmlselect.red"/&gt;<br />
</span><span style="font-size: 9pt; color: black">它和配置文件中的</span><span style="font-size: 9pt; color: black">&lt;message-resources&gt;</span><span style="font-size: 9pt; color: black">元素的</span><span style="font-size: 9pt; color: black">key</span><span style="font-size: 9pt; color: black">属性匹配</span><span style="font-size: 9pt; color: black"> --&gt; &lt;message-resource parmeter="HtmlSelectColors" key="htmlselect.Colors"/&gt;<br />
&lt;message-resource&gt;</span><span style="font-size: 9pt; color: black">中配置的资源文件为</span><span style="font-size: 9pt; color: black">HtmlSelectColors.properties</span><span style="font-size: 9pt; color: black">，相关内容为</span><span style="font-size: 9pt; color: black"> htmlselect.red=RED<br />
<strong>&lt;html:options&gt;</strong></span><span style="font-size: 9pt; color: black">标签，提供了一组</span><span style="font-size: 9pt; color: black">&lt;option&gt;</span><span style="font-size: 9pt; color: black">元素，在</span><span style="font-size: 9pt; color: black">&lt;html:select&gt;</span><span style="font-size: 9pt; color: black">元素中可以包含多个</span><span style="font-size: 9pt; color: black">&lt;html:options&gt;</span><span style="font-size: 9pt; color: black">元素。非常灵活，可以取得集合或数组中的值。</span><span style="font-size: 9pt; color: black"><br />
</span><span style="font-size: 9pt; color: black">例</span><span style="font-size: 9pt; color: black">1 &lt;html:options collection="coll" property="value" labelProperty="label" /&gt; </span><span style="font-size: 9pt; color: black">这指在</span><span style="font-size: 9pt; color: black">coll</span><span style="font-size: 9pt; color: black">的集合中存放了</span><span style="font-size: 9pt; color: black">options</span><span style="font-size: 9pt; color: black">，</span><span style="font-size: 9pt; color: black">value</span><span style="font-size: 9pt; color: black">指实际能被提交的值，</span><span style="font-size: 9pt; color: black">label</span><span style="font-size: 9pt; color: black">是显示给用户的值。</span><span style="font-size: 9pt; color: black"><br />
</span><span style="font-size: 9pt; color: black">例</span><span style="font-size: 9pt; color: black">2 &lt;html:options property="value" labelProperty="label" /&gt; collection</span><span style="font-size: 9pt; color: black">属性不被指定时，将使用表单相关的</span><span style="font-size: 9pt; color: black">form bean</span><span style="font-size: 9pt; color: black">，</span><span style="font-size: 9pt; color: black">form bean</span><span style="font-size: 9pt; color: black">中</span><span style="font-size: 9pt; color: black">value</span><span style="font-size: 9pt; color: black">属性存放</span><span style="font-size: 9pt; color: black">option value</span><span style="font-size: 9pt; color: black">，</span><span style="font-size: 9pt; color: black">label</span><span style="font-size: 9pt; color: black">属性值显示给用户。</span><span style="font-size: 9pt; color: black"><br />
</span><span style="font-size: 9pt; color: black">例</span><span style="font-size: 9pt; color: black">3 &lt;html:options name="valueBean" property="values" labelName="labelsBean" labelProperty="labels" /&gt; </span><span style="font-size: 9pt; color: black">这个意思是</span><span style="font-size: 9pt; color: black">value</span><span style="font-size: 9pt; color: black">值存放在名为</span><span style="font-size: 9pt; color: black">valueBean</span><span style="font-size: 9pt; color: black">的</span><span style="font-size: 9pt; color: black">bean</span><span style="font-size: 9pt; color: black">的</span><span style="font-size: 9pt; color: black">vlaues</span><span style="font-size: 9pt; color: black">属性中，它是一个</span><span style="font-size: 9pt; color: black">collection</span><span style="font-size: 9pt; color: black">；</span><span style="font-size: 9pt; color: black">label</span><span style="font-size: 9pt; color: black">值也是同样的意思。</span><span style="font-size: 9pt; color: black"><br />
<strong>&lt;html:optionsCollection&gt;</strong></span><span style="font-size: 9pt; color: black">标签，和</span><span style="font-size: 9pt; color: black">&lt;html:options&gt;</span><span style="font-size: 9pt; color: black">的用法很相似。</span><span style="font-size: 9pt; color: black"><br />
</span><span style="font-size: 9pt; color: black">例如</span><span style="font-size: 9pt; color: black"> &lt;html:select property="custId"&gt;&lt;html:optionsCollection property="customers" label="name" value="custId" /&gt;&lt;/html:select&gt;<br />
</span><span style="font-size: 9pt; color: black">这个标签和</span><span style="font-size: 9pt; color: black">org.apache.structs.util.LabelValueBean</span><span style="font-size: 9pt; color: black">结合的很好，如果把</span><span style="font-size: 9pt; color: black">label</span><span style="font-size: 9pt; color: black">和</span><span style="font-size: 9pt; color: black">value</span><span style="font-size: 9pt; color: black">都放到这个对象中，可以很简单的这样应用：</span><span style="font-size: 9pt; color: black"><br />
&lt;html:select property="custId"&gt;&lt;html:optionsCollection property="customers" /&gt;&lt;/html:select&gt;</span></div>
<img src ="http://www.blogjava.net/DreamFight/aggbug/254757.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/DreamFight/" target="_blank">DreamFight</a> 2009-02-15 15:30 <a href="http://www.blogjava.net/DreamFight/articles/254757.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts标签库详解(1)</title><link>http://www.blogjava.net/DreamFight/articles/254756.html</link><dc:creator>DreamFight</dc:creator><author>DreamFight</author><pubDate>Sun, 15 Feb 2009 07:29:00 GMT</pubDate><guid>http://www.blogjava.net/DreamFight/articles/254756.html</guid><wfw:comment>http://www.blogjava.net/DreamFight/comments/254756.html</wfw:comment><comments>http://www.blogjava.net/DreamFight/articles/254756.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/DreamFight/comments/commentRss/254756.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/DreamFight/services/trackbacks/254756.html</trackback:ping><description><![CDATA[<div align="left"><span style="font-size: 9pt">Struts</span><span style="font-size: 9pt">提供了五个标签库，即：</span><span style="font-size: 9pt">HTML</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">Bean</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">Logic</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">Template</span><span style="font-size: 9pt">和</span><span style="font-size: 9pt">Nested</span><span style="font-size: 9pt">。</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 480pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="640" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="center"><span style="font-size: 9pt">标签库</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="center"><span style="font-size: 9pt">说明</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">HTML </span><span style="font-size: 9pt">标签</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">用来创建能够和</span><span style="font-size: 9pt">Struts </span><span style="font-size: 9pt">框架和其他相应的</span><span style="font-size: 9pt">HTML </span><span style="font-size: 9pt">标签交互的</span><span style="font-size: 9pt">HTML </span><span style="font-size: 9pt">输入表单</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">Bean </span><span style="font-size: 9pt">标签</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">在访问</span><span style="font-size: 9pt">JavaBeans </span><span style="font-size: 9pt">及其属性，以及定义一个新的</span><span style="font-size: 9pt">bean </span><span style="font-size: 9pt">时使用</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">Logic </span><span style="font-size: 9pt">标签</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">管理条件产生的输出和对象集产生的循环</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">Template </span><span style="font-size: 9pt">标签</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">随着</span><span style="font-size: 9pt">Tiles</span><span style="font-size: 9pt">框架包的出现，此标记已开始减少使用</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">Nested </span><span style="font-size: 9pt">标签</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">增强对其他的</span><span style="font-size: 9pt">Struts </span><span style="font-size: 9pt">标签的嵌套使用的能力</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"></div>
<div align="left"><strong><span style="font-size: 9pt">标签的公共特征</span></strong></div>
<div align="left"></div>
<div align="left"><span style="font-size: 9pt">使用固定属性名称的</span><span style="font-size: 9pt">Struts </span><span style="font-size: 9pt">标签：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 490.5pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="654" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="center"><span style="font-size: 9pt">属性</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="center"><span style="font-size: 9pt">说明</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">id</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">命名自定义标签创建时的脚本变量名。</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">name</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">指出关键字值，在该关键字下可以找到一个存在的</span><span style="font-size: 9pt">bean </span><span style="font-size: 9pt">。如果给出了</span><span style="font-size: 9pt">scope</span><span style="font-size: 9pt">属性，则仅仅在</span><span style="font-size: 9pt">scope</span><span style="font-size: 9pt">中查找。否则，根据标准的顺序在各种</span><span style="font-size: 9pt">scope</span><span style="font-size: 9pt">中查找：</span><span style="font-size: 9pt">(page, request, session, or application)</span><span style="font-size: 9pt">。</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">property</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">指出</span><span style="font-size: 9pt">bean </span><span style="font-size: 9pt">中的某个属性，可以在其中检索值。如果没有标明，则使用对象本身的值。</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">scope</span></div>
            </td>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">定义了</span><span style="font-size: 9pt">Bean</span><span style="font-size: 9pt">在哪个范围</span><span style="font-size: 9pt">(page, request, session, or application)</span><span style="font-size: 9pt">中被查找。如果没有标明按顺序查找。脚本变量</span><span style="font-size: 9pt">(</span><span style="font-size: 9pt">见</span><span style="font-size: 9pt">id)</span><span style="font-size: 9pt">将在相同的范围中创建。</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"></div>
<div align="left"><span style="font-size: 9pt">Struts </span><span style="font-size: 9pt">标签也支持嵌套引用，例如：</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; border-left: black 0.75pt outset; width: 488.2pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="651" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 486.8pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="649">
            <div align="left"><span style="font-size: 9pt">Property="foo.bar.baz"<br />
            <br />
            </span><span style="font-size: 9pt">这相当于进行下面的调用：</span><span style="font-size: 9pt"><br />
            getFoo().getBar().getBaz()</span><span style="font-size: 9pt">；</span><span style="font-size: 9pt"><br />
            <br />
            </span><span style="font-size: 9pt">或者做为</span><span style="font-size: 9pt">setter</span><span style="font-size: 9pt">：</span><span style="font-size: 9pt"><br />
            getFoo().getBar().setBaz(value)</span><span style="font-size: 9pt">；</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div align="left"></div>
<div align="left"><span style="font-size: 9pt">虽然</span><span style="font-size: 9pt">Struts </span><span style="font-size: 9pt">标签的设计原意是为了避免使用</span><span style="font-size: 9pt">scriptlet</span><span style="font-size: 9pt">，</span><span style="font-size: 9pt">scriptlet</span><span style="font-size: 9pt">的表达式还能够提供给所有的</span><span style="font-size: 9pt">Struts </span><span style="font-size: 9pt">标签使用。但请确保使用完整的表达式</span><span style="font-size: 9pt">:</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; margin-left: 1.45pt; border-left: black 0.75pt outset; width: 477.75pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="637" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 476.35pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="635">
            <div align="left"><span style="font-size: 9pt">错误：</span><span style="font-size: 9pt"><br />
            &lt;html:link href="'&lt;%= "/" + name %&gt;/index.jsp&gt;'&gt;<br />
            <br />
            </span><span style="font-size: 9pt">正确：</span><span style="font-size: 9pt"><br />
            &lt;html:link href="'&lt;%= "/" + name + "/index.jsp" %&gt;'&gt;&nbsp;&nbsp;&nbsp; // </span><span style="font-size: 9pt">表达式必须提供整个属性值</span></div>
            </td>
        </tr>
    </tbody>
</table>
<br />
<div align="left"><strong><span style="font-size: 9pt">Html </span></strong><strong><span style="font-size: 9pt">标签库</span></strong></div>
<div style="margin-left: 36pt; text-indent: -18pt; text-align: left" align="left"><span style="font-size: 9pt">1.<span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal; font-size-adjust: none; font-stretch: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9pt">&lt;html&gt;</span><span style="font-size: 9pt">标签</span><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt">它有两个属性：</span><span style="font-size: 9pt">locale</span><span style="font-size: 9pt">和</span><span style="font-size: 9pt">xhtml</span><span style="font-size: 9pt">，两者都不是必需的。</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; margin-left: 36pt; border-left: black 0.75pt outset; width: 395.25pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="527" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">&lt;html:html locale=\"true\"&gt;<br />
            <br />
            </span><span style="font-size: 9pt">此行代码解析后：</span><span style="font-size: 9pt"><br />
            &lt;html lang=\"en\"&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div style="margin-left: 36pt; text-indent: -18pt; text-align: left" align="left"><span style="font-size: 9pt">2.<span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal; font-size-adjust: none; font-stretch: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9pt">说明：生成的结果取决于</span><span style="font-size: 9pt">Struts</span><span style="font-size: 9pt">应用程序所位于的服务器的</span><span style="font-size: 9pt">locale</span><span style="font-size: 9pt">。如果你将应用程序部署到一个不同</span><span style="font-size: 9pt">locale</span><span style="font-size: 9pt">的服务器，你不需要改变代码，</span><span style="font-size: 9pt">Locale</span><span style="font-size: 9pt">会自动调整。</span></div>
<div style="margin-left: 36pt; text-indent: -18pt; text-align: left" align="left"><span style="font-size: 9pt">3.<span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal; font-size-adjust: none; font-stretch: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9pt">&lt;base&gt;</span><span style="font-size: 9pt">标签：表示所包含页面的绝对位置。这个标签只有内嵌在</span><span style="font-size: 9pt">head</span><span style="font-size: 9pt">标签中才有效。</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; margin-left: 36pt; border-left: black 0.75pt outset; width: 378.75pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="505" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">&lt;html:base/&gt;<br />
            <br />
            </span><span style="font-size: 9pt">此行代码解析后：</span><span style="font-size: 9pt"><br />
            &lt;base href=\"http://www.mymain.com/myStrutsApp/testing.jsp\"&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div style="margin-left: 36pt; text-indent: -18pt; text-align: left" align="left"><span style="font-size: 9pt">4.<span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal; font-size-adjust: none; font-stretch: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9pt">&lt;img&gt;</span><span style="font-size: 9pt">标签</span><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt">最重要的属性</span><span style="font-size: 9pt">page</span><span style="font-size: 9pt">：图象文件的路径，前面必须带有一个斜线。</span><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt">其它属性：</span><span style="font-size: 9pt">heignt</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">width</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">alt</span><span style="font-size: 9pt">。</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; margin-left: 36pt; border-left: black 0.75pt outset; width: 436.5pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="582" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">&nbsp;&nbsp; &lt;html:img page=\"/logo.gif\" height=\"50\" width=\"200\" alt=\"Web Logo\"/&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div style="margin-left: 36pt; text-indent: -18pt; text-align: left" align="left"><span style="font-size: 9pt">5.<span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal; font-size-adjust: none; font-stretch: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9pt">&lt;link&gt;</span><span style="font-size: 9pt">标签</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; margin-left: 36pt; border-left: black 0.75pt outset; width: 440.25pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="587" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">&lt;html:link page=\"/index.html\"&gt;Click demo&lt;/html:link&gt;<br />
            <br />
            </span><span style="font-size: 9pt">此行代码解析后：</span><span style="font-size: 9pt"><br />
            &nbsp;&nbsp; &lt;a href=\"/index.html\"&gt;Click demo&lt;/a&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div style="margin-left: 36pt; text-indent: -18pt; text-align: left" align="left"><span style="font-size: 9pt">6.<span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal; font-size-adjust: none; font-stretch: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9pt">&lt;errors&gt;</span><span style="font-size: 9pt">标签：通过一个简单的</span><span style="font-size: 9pt">&lt;html:errors/&gt;</span><span style="font-size: 9pt">标签，你就可以在一个</span><span style="font-size: 9pt">JSP</span><span style="font-size: 9pt">页面上显示完全自定义的错误信息。功能超强大！！</span><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt">说明：这个标签在</span><span style="font-size: 9pt">Request</span><span style="font-size: 9pt">对象的属性集合中查找</span><span style="font-size: 9pt">reserved key</span><span style="font-size: 9pt">。如果它找到一个</span><span style="font-size: 9pt">reserved key</span><span style="font-size: 9pt">，它就假设这个</span><span style="font-size: 9pt">key</span><span style="font-size: 9pt">是一个</span><span style="font-size: 9pt">String</span><span style="font-size: 9pt">、或是一个</span><span style="font-size: 9pt">String</span><span style="font-size: 9pt">数组</span><span style="font-size: 9pt">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt">（它包含在模块的</span><span style="font-size: 9pt">MessageResources</span><span style="font-size: 9pt">中查找的</span><span style="font-size: 9pt">message keys</span><span style="font-size: 9pt">）、或是类型为</span><span style="font-size: 9pt">org.apache.struts.action.ActionErrors</span><span style="font-size: 9pt">的一个对象。</span><span style="font-size: 9pt"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt">如果在应用程序资源中存在相应的信息，那么就可以用下面这些可选的</span><span style="font-size: 9pt">message keys</span><span style="font-size: 9pt">：</span><span style="font-size: 9pt">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#183; errors.header&nbsp;&nbsp; or errors.prefix</span><span style="font-size: 9pt">：相应的信息在错误信息的单独列表前显示。</span><span style="font-size: 9pt"> <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#183; errors.footer or errors.suffix</span><span style="font-size: 9pt">：相应的信息在错误信息的单独列表后显示。</span></div>
<div style="margin-left: 36pt; text-indent: -18pt; text-align: left" align="left"><span style="font-size: 9pt">7.<span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal; font-size-adjust: none; font-stretch: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9pt">&lt;form&gt;</span><span style="font-size: 9pt">标签系列</span><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt">使用</span><span style="font-size: 9pt">&lt;form&gt;</span><span style="font-size: 9pt">标签时必须遵循一些规则：</span></div>
<div style="margin-left: 72pt; text-indent: -18pt; text-align: left" align="left"><span style="font-size: 9pt">1.<span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal; font-size-adjust: none; font-stretch: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9pt">标签中必须包含一个</span><span style="font-size: 9pt">action</span><span style="font-size: 9pt">属性，它是这个标签中唯一必需的属性。如果不具备该属性则</span><span style="font-size: 9pt">JSP</span><span style="font-size: 9pt">页面会抛出一个异常。之后你必须给这个</span><span style="font-size: 9pt">action</span><span style="font-size: 9pt">属性指定一个有效值。一个有效值是指应用程序的</span><span style="font-size: 9pt">Struts</span><span style="font-size: 9pt">配置文件中元素里的任何一个子元素的访问路径。而且相应的元素中必须有一个</span><span style="font-size: 9pt">name</span><span style="font-size: 9pt">属性，它的值是</span><span style="font-size: 9pt">form bean</span><span style="font-size: 9pt">的名称。</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; margin-left: 1.45pt; border-left: black 0.75pt outset; width: 468pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="624" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; padding-top: 0.75pt; border-bottom: black 0.75pt inset">
            <div align="left"><span style="font-size: 9pt">&lt;html:form action=\"/login\" &gt; <br />
            <br />
            </span><span style="font-size: 9pt">如果你有上述一个标签</span> <span style="font-size: 9pt">，那么你的</span><span style="font-size: 9pt">Struts</span><span style="font-size: 9pt">配置文件的元素中必须有一个如下显示为粗体的元素：</span><span style="font-size: 9pt"> <br />
            &lt;action-mappings&gt; <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;action path=\"/login\" <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type=\"com.javapro.struts.LoginAction\"&nbsp;&nbsp;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name=\"loginForm\"<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scope=\"request\"<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; input=\"/login.jsp\"&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;forward name=\"success\" path=\"/mainMenu.jsp\"/&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp; &lt;/action&gt;<br />
            &nbsp;&nbsp;&nbsp;&nbsp; .<br />
            &nbsp;&nbsp;&nbsp;&nbsp; .<br />
            &nbsp;&nbsp;&nbsp;&nbsp; .<br />
            &lt;/action-mappings&gt; // </span><span style="font-size: 9pt">这就是说一个</span><span style="font-size: 9pt">form</span><span style="font-size: 9pt">标签是和</span><span style="font-size: 9pt">form bean</span><span style="font-size: 9pt">相关联的。</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div style="margin-left: 72pt; text-indent: -18pt; text-align: left" align="left"><span style="font-size: 9pt">2.<span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal; font-size-adjust: none; font-stretch: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></div>
<div style="margin-left: 72pt; text-indent: -18pt; text-align: left" align="left"><span style="font-size: 9pt">3.<span style="font-weight: normal; font-size: 7pt; line-height: normal; font-style: normal; font-variant: normal; font-size-adjust: none; font-stretch: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9pt">任何包含在</span><span style="font-size: 9pt">&lt;form&gt;</span><span style="font-size: 9pt">中用来接收用户输入的标签（</span><span style="font-size: 9pt">&lt;text&gt;</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">&lt;password&gt;</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">&lt;hidden&gt;</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">&lt;textarea&gt;</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">&lt;radio&gt;</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">&lt;checkbox&gt;</span><span style="font-size: 9pt">、</span><span style="font-size: 9pt">&lt;select&gt;</span><span style="font-size: 9pt">）必须在相关的</span><span style="font-size: 9pt">form bean</span><span style="font-size: 9pt">中有一个指定的属性值。比如，如果你有一个属性值被指定为</span><span style="font-size: 9pt">&#8220;username&#8221;</span><span style="font-size: 9pt">的</span><span style="font-size: 9pt">&lt;text&gt;</span><span style="font-size: 9pt">标签，那么相关的</span><span style="font-size: 9pt">form bean</span><span style="font-size: 9pt">中也必须有一个名为</span><span style="font-size: 9pt">&#8220;username&#8221;</span><span style="font-size: 9pt">的属性。输入</span><span style="font-size: 9pt">&lt;text&gt;</span><span style="font-size: 9pt">标签中的值会被用于生成</span><span style="font-size: 9pt">form bean</span><span style="font-size: 9pt">的</span><span style="font-size: 9pt">userName</span><span style="font-size: 9pt">属性。</span></div>
<div style="margin-left: 36pt" align="left"><span style="font-size: 9pt"><br />
&lt;form&gt;</span><span style="font-size: 9pt">标签还有一些不是必须但很有用的</span><span style="font-size: 9pt">&#8220;</span><span style="font-size: 9pt">次要</span><span style="font-size: 9pt">&#8221;</span><span style="font-size: 9pt">属性。</span><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt">比如，你可以用</span><span style="font-size: 9pt">focus</span><span style="font-size: 9pt">属性来生成</span><span style="font-size: 9pt">JavaScript</span><span style="font-size: 9pt">，它会</span><span style="font-size: 9pt">&#8220;</span><span style="font-size: 9pt">定焦</span><span style="font-size: 9pt">&#8221;</span><span style="font-size: 9pt">（</span><span style="font-size: 9pt">focus</span><span style="font-size: 9pt">）到该</span><span style="font-size: 9pt">form</span><span style="font-size: 9pt">所包含的一个元素上。使用</span><span style="font-size: 9pt">focus</span><span style="font-size: 9pt">属性时你需要给它指定元素的名称。</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; margin-left: 1.45pt; border-left: black 0.75pt outset; width: 468.75pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="625" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 467.35pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="623">
            <div align="left"><span style="font-size: 9pt">&lt;body&gt;<br />
            &lt;html:form action=\"/login\" focus=\"password\"&gt;<br />
            User Name: &lt;html:text property=\"userName\"/&gt;<br />
            &lt;br&gt;Password: &lt;html:text property=\"password\"/&gt;<br />
            &lt;br&gt;&lt;html:submit/&gt;<br />
            &lt;/html:form&gt;<br />
            &lt;/body&gt;<br />
            <br />
            </span><span style="font-size: 9pt">代码解析后：</span><span style="font-size: 9pt"><br />
            &lt;body&gt;<br />
            &lt;form name=\"loginForm\" method=\"post\" action=\"/myStrutsApp/login.do\"&gt;<br />
            User Name: &lt;input type=\"text\" name=\"userName\" value=\"\"&gt;<br />
            &lt;br&gt;Password: &lt;input type=\"text\" name=\"password\" value=\"\"&gt;<br />
            &lt;br&gt;&lt;input type=\"submit\" value=\"Submit\"&gt;<br />
            &lt;/form&gt;<br />
            &lt;script language=\"JavaScript\" type=\"text/javascript\"&gt;<br />
            &nbsp;&nbsp; &lt;!--<br />
            if (document.forms[\"loginForm\"].elements[\"password\"].type != \"hidden\") <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.forms[\"loginForm\"].elements[\"password\"].focus()<br />
            &nbsp;&nbsp; // --&gt;<br />
            &lt;/script&gt;<br />
            <br />
            &lt;/body&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div style="margin-left: 36pt" align="left"><span style="font-size: 9pt">有没有看到这个标签库是如何建立</span><span style="font-size: 9pt">JavaScript</span><span style="font-size: 9pt">来定焦到</span><span style="font-size: 9pt">password</span><span style="font-size: 9pt">元素上的</span><span style="font-size: 9pt">? </span><span style="font-size: 9pt">这也是该库让人着迷的地方之一。你不用担心如何在客户端进行编程，它会帮你自动生成。</span><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt">还可以看到，</span><span style="font-size: 9pt">&lt;form&gt;</span><span style="font-size: 9pt">标签中</span><span style="font-size: 9pt">method</span><span style="font-size: 9pt">属性的缺省值是</span><span style="font-size: 9pt">POST</span><span style="font-size: 9pt">。</span><span style="font-size: 9pt"><br />
<br />
&lt;text&gt;</span><span style="font-size: 9pt">标签、</span><span style="font-size: 9pt">&lt;hidden&gt;</span><span style="font-size: 9pt">标签、</span><span style="font-size: 9pt">&lt;textarea&gt;</span><span style="font-size: 9pt">标签、</span><span style="font-size: 9pt">&lt;radio&gt;</span><span style="font-size: 9pt">标签、</span><span style="font-size: 9pt">&lt;checkbox&gt;</span><span style="font-size: 9pt">标签、</span><span style="font-size: 9pt">&lt;submit&gt;</span><span style="font-size: 9pt">标签、</span><span style="font-size: 9pt">&lt;reset&gt;</span><span style="font-size: 9pt">标签：</span><span style="font-size: 9pt"><br />
</span><span style="font-size: 9pt">都有一个</span><span style="font-size: 9pt">property</span><span style="font-size: 9pt">属性，最后会被转换成</span><span style="font-size: 9pt">HTML</span><span style="font-size: 9pt">中的</span><span style="font-size: 9pt">name</span><span style="font-size: 9pt">属性，当然还有</span><span style="font-size: 9pt">name</span><span style="font-size: 9pt">和</span><span style="font-size: 9pt">value</span><span style="font-size: 9pt">属性。</span><span style="font-size: 9pt"><br />
<br />
&lt;password&gt;</span><span style="font-size: 9pt">标签</span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; margin-left: 28.45pt; border-left: black 0.75pt outset; width: 432.75pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="577" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 431.35pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="575">
            <div align="left"><span style="font-size: 9pt">&nbsp;&nbsp; &lt;html:password property=\"password\"&nbsp;&nbsp; redisplay=\"false\"/&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<div style="margin-left: 36pt" align="left"><span style="font-size: 9pt">该标签中的一个很重要的属性是</span><span style="font-size: 9pt">"redisplay"</span><span style="font-size: 9pt">，它用于重新显示以前输入到这个区域中的值。该属性的缺省值为</span><span style="font-size: 9pt">true</span><span style="font-size: 9pt">。然而，为了使</span><span style="font-size: 9pt">password</span><span style="font-size: 9pt">不能被重新显示，你或许希望将该属性的值设为</span><span style="font-size: 9pt">false</span><span style="font-size: 9pt">。</span><span style="font-size: 9pt"><br />
<br />
&lt;select&gt;</span><span style="font-size: 9pt">标签和</span><span style="font-size: 9pt">&lt;option&gt;</span><span style="font-size: 9pt">标签：</span><span style="font-size: 9pt"> </span></div>
<table style="border-right: black 0.75pt outset; border-top: black 0.75pt outset; background: rgb(255,255,204) 0% 50%; margin-left: 1.45pt; border-left: black 0.75pt outset; width: 459.75pt; border-bottom: black 0.75pt outset; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial" cellspacing="1" cellpadding="0" width="613" bgcolor="#ffffcc" border="1">
    <tbody>
        <tr>
            <td style="border-right: black 0.75pt inset; padding-right: 0.75pt; border-top: black 0.75pt inset; padding-left: 0.75pt; padding-bottom: 0.75pt; border-left: black 0.75pt inset; width: 458.35pt; padding-top: 0.75pt; border-bottom: black 0.75pt inset" width="611">
            <div align="left"><span style="font-size: 9pt">&lt;html:select property=\"color\" size=\"3\"&gt;<br />
            &nbsp;&nbsp; &lt;html:option value=\"r\"&gt;red&lt;/html:option&gt;<br />
            &nbsp;&nbsp; &lt;html:option value= \"g\"&gt;green&lt;/html:option&gt;<br />
            &nbsp;&nbsp; &lt;html:option value= \"b\"&gt;blue&lt;/html:option&gt;<br />
            &lt;/html:select&gt;</span></div>
            </td>
        </tr>
    </tbody>
</table>
<br />
 <img src ="http://www.blogjava.net/DreamFight/aggbug/254756.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/DreamFight/" target="_blank">DreamFight</a> 2009-02-15 15:29 <a href="http://www.blogjava.net/DreamFight/articles/254756.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>