The simplest demonstration of using indexed properties in Struts can be shown with the following simple bean and JSP page:
First note the two methods in the StringBean class, "getStringIndexed()" and "setStringIndexed()". Note that the "get" method takes an "int" and the "set" method takes an "int" and "String". The Beanutils package and Struts recognizes this arrangement of signatures as an "indexed property", in this case with the property name "stringIndexed".
Note the property value of "stringIndexed[1]". This is intended to reference the indexed property "stringIndexed", and the 1st (zero-based) entry of whatever array or collection which the indexed property represents.
As you might be able to guess, when this page is executed, it will print just the string "String 1", which is the corresponding array entry at that index value.
This is a simple demonstration of what indexed properties can provide.
本文通过一个简单的Bean和JSP页面演示了如何在Struts中使用索引属性。示例Bean包含两个方法:getStringIndexed()和setStringIndexed(),Struts将这两种签名视为索引属性。执行页面时,它会打印出对应数组条目的字符串。
670

被折叠的 条评论
为什么被折叠?



