发现struts列表标签的一个弊端,各位是否碰到?
今天发现struts中的html:option标签的一个问题:
当需要初始化页面列表值时,只能初始化静态的option,即在页面中已经写好了的:
<html:select property="selected">
<html:option value="value1">label1</html:option>
<html:option value="value2">label2</html:option>
<html:option value="value3">label3</html:option>
...
</html:select>
而对应在页面初始时动态生成的option值就不能对其进行初始化,如下:
<html:select property="selected">
<html:optionsCollection property="itemCollection" />
</html:select>
本人认为原因可能是在页面生成时首先进行了selected的初始化,然后才进行itemCollection的解析,于是无法找到对应的value值。
对于这种情况,大家是如何解决的。