关于孙<精通struts>中例子的问题?

wafer_w 2005-09-29 11:38:03
在讲<html:select>标签时(311页)时,HtmlSelect.jsp代码如下:
<%@ page language="java" import="htmltaglibs.beans.*, java.util.*" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html>
<head>
<title>Select and Option Tags</title>
</head>
<body bgcolor="white">

<h3>Select and Option Tags</h3>
<p>This page provides examples of the following Struts HTML tags:<br>
<ul>
<li><html:select></li>
<li><html:option></li>
<li><html:options></li>
<li><html:optionsCollection></li>
</ul>
<html:form action="HtmlSelect.do">

<table border="1" width="100%">

<tr>

<%
Vector colorCollection = new Vector();
colorCollection.add(
new org.apache.struts.util.LabelValueBean("Pink", "htmlselect.pink"));
colorCollection.add(
new org.apache.struts.util.LabelValueBean("Brown", "htmlselect.brown"));
pageContext.setAttribute("colorCollection", colorCollection);
%>

<th align="left" width="25%" >Select a customer: </th>

<th align="left" width="25%" >Select some colors: </th>

<th align="left" width="50%" >You last submitted: </th>

</tr>

<tr>

<td align="left" width="25%" >
<html:select property="custId">
<html:optionsCollection property="customers"
label="name"
value="custId" />
</html:select>
</td>
<td align="left" width="25%" >
<html:select property="colors" size="6" multiple="true" >

<%-- Specify some options using the basic version of the tag --%>
<html:option value="htmlselect.orange">Orange</html:option>
<html:option value="htmlselect.purple">Purple</html:option>

<%-- Specify some by referring to a properties file --%>
<html:option value="htmlselect.red" bundle="htmlselect.Colors" key="htmlselect.red"/>
<html:option value="htmlselect.blue" bundle="htmlselect.Colors" key="htmlselect.blue"/>

<%-- Specify some from our collection of LabelValueBean's --%>
<html:options collection="colorCollection"
property="value"
labelProperty="label" />

</html:select>
</td>

<td align="left" width="50%" >
<logic:present name="HtmlSelectForm" scope="session">
<ul>
<li>Name: <bean:write name="HtmlSelectForm" property="cust.name" />
<logic:iterate id="element" name="HtmlSelectForm" property="cust.favColors">
<li>Colors: <bean:write name="element" />
</logic:iterate>
</ul>
</logic:present>
</td>

</tr>

</table>

<table border="0" width="100%">
<tr>
<td align="left" width="20%"> </td>
<td align="left">
<html:submit>Submit</html:submit>
<html:reset>Reset</html:reset>
<html:cancel>Cancel</html:cancel>
</td>
</tr>

</table>

</html:form>
</html:html>
---
此代码并未对HtmlSelectForm进行定义,如何能引用其属性和方法?
...全文
181 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
首先<html:form action="HtmlSelect.do"></hmlt:form>这个范围内的ActionForm都是可用的。
再看strusts-config.xml中的配置:
<action path="/HtmlSelect"
type="htmltaglibs.actions.HtmlSelectAction"
name="HtmlSelectForm"
scope="session"
input="/HtmlSelect.jsp"
validate="true">
<forward name="success" path="/HtmlSelect.jsp"/>
</action>
ActionForm是session范围内的HtmlSelectForm。
最后,这个HtmlSelectForm是定义了的,
<form-bean name="HtmlSelectForm" type="htmltaglibs.forms.HtmlSelectForm"/>

不知道你问的是不是这个意思。

50,527

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧