简体   繁体   English

如何将html:options集合转换为html:optionsCollection

[英]how to convert html:options collection into html:optionsCollection

how to convert the statement of 如何转换语句

    <html:options collection='catList' property='catId' labelProperty='catName'>        

by using <html:optionsCollection>. 通过使用<html:optionsCollection>.

From the documentation on the <html:options> tag, the collections attribute is ( http://people.apache.org/~germuska/struts-taglib/docs/tlddoc/html/options.html ): <html:options>标记的文档中, collections属性为( http://people.apache.org/~germuska/struts-taglib/docs/tlddoc/html/options.html ):

Name of the JSP bean (in some scope) which is itself a Collection of other beans, each of which has properties named by the "property" and "labelProperty" attributes that are used to retrieve the value and label for each option, respectively. JSP bean的名称(在一定范围内)本身就是其他bean的集合,每个bean具有以“ property”和“ labelProperty”属性命名的属性,这些属性分别用于检索每个选项的值和标签。

So your catList is a collection of beans (that can be in any scope) that have the property catId which will be the value for the select and catName which will be the displayed label in the select. 因此,您的catList是一个bean的集合(可以在任何范围内),这些bean具有属性catId (将作为select的值)和catName (将在select中显示的标签)。

To translate this to <html:optionsCollection> tag, We should look at the documentation ( http://people.apache.org/~germuska/struts-taglib/docs/tlddoc/html/optionsCollection.html ) : 要将其翻译为<html:optionsCollection>标记,我们应该查看文档( http://people.apache.org/~germuska/struts-taglib/docs/tlddoc/html/optionsCollection.html ):

This tag differs from the <html:options> tag in that it makes more consistent use of the name and property attributes, and allows the collection to be more easily obtained from the enclosing form bean. 此标记与<html:options>标记的不同之处在于,它更一致地使用了name和property属性,并允许从封闭的Form Bean中更轻松地获取集合。

So essentially its using different attributes for the same things to make the wording more consistent. 因此,从本质上讲,它对同一事物使用不同的属性以使措词更加一致。 In this case it should look something like: 在这种情况下,它应该类似于:

<html:optionsCollection property="catList" value="catId" label="catName">

This will get the collection catList from the bean that is on the current form and use the catId in each of those objects as the value and catName as the label. 这将让集合catList从在当前窗体上的豆和使用catId在每个这些对象的价值和catName作为标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM