|
1. html:base
同html的base元素。
2. html:cancel
该标签生成一个取消按钮。当点击该按钮后action servlet会绕过相应的form bean的validate()方法,同时将控制权交给相应的action。在action中可使用Action.isCancelled(HttpServletRequest)方法判断是否被取消了。如果返回true表示这个action被取消了,否则表示这个action没有被取消。 eg. <html:cancel>取消</html:cancel>
3. html:select
该标签生成一个select元素。multiple属性决定是否为多选。如果指定了multiple="true"则为多选,此时对应的属性应该是一个数组。否则,此时对应的属性应该是标量。
注意:为了正确的处理未作选择的情况,在ActionForm中的reset()方法中必须将标量属性设置为默认值而将数组的长度置为0。
另外的一个重要问题就是struts如何生成option元素了,这个任务struts交给了html:option、html:options和html:optionsCollection三个标签。
1)html:option
该标签生成一个HTML的option元素。该标签必须嵌在html:select标签中。它的显示文本来自其标签体,也可以来自于资源文件。 <html:option value="red">red</html:option> <html:option value="blue">blue</html:option>
2)html:options
该标签生成多个HTML的option元素。该标签必须嵌在html:select标签中。
指定collection属性的方式举例如下: <html:select name="selectForm" property="orgId" size="1"> <html:options collection="orgCollection" property="orgId" labelProperty="orgName"/> </html:select>
未指定collection属性方式的举例如下: <html:select name="selectForm" property="orgId" size="1"> <html:options property="orgIds" labelProperty="orgNames"/> </html:select>
3)html:optionsCollection标签
该标签生成多个HTML的option元素。其功能和html:options标签的相同。 <html:select name="selectForm" property="orgIds" size="1"> <html:optionsCollection name="selectForm" property="orgs" label="orgName" value="orgId"/> </html:select>
|