如何实现从Session中取出一个list,用取出来的listdata来初始化一个select的options?用struts来实现~
来源:百度知道 编辑:UC知道 时间:2024/06/03 21:32:43
如何实现从Session中取出一个list,用取出来的listdata来初始化一个select的options?用struts来实现~
Java code
<html:select property="temp1" style="font-size:12">
<html:options/>
</html:select>
需要在那几个页面做设置啊?
做关键的把Session中的list传给options怎么实现呢?
大家能给写个代码的例子,我学习下吗?O(∩_∩)O谢谢~在线等~~
PS:struts中options标签的labelProperty是啥意思?咋用?
1L 你好,你的做法不是struts的,我需要struts的,不过也O(∩_∩)O谢谢啊~
Java code
<html:select property="temp1" style="font-size:12">
<html:options/>
</html:select>
需要在那几个页面做设置啊?
做关键的把Session中的list传给options怎么实现呢?
大家能给写个代码的例子,我学习下吗?O(∩_∩)O谢谢~在线等~~
PS:struts中options标签的labelProperty是啥意思?咋用?
1L 你好,你的做法不是struts的,我需要struts的,不过也O(∩_∩)O谢谢啊~
用的是struts1是吧?
<html:select property="temp.tempId">
//temp.tempId是你所要绑定的from值
//我这里用的是动态form,你如果用静态也可以
//<form-property name="temp" type="com.test.entity.temp">
//</form-property>
<html:optionsCollection name="tempList" label="tempName value="tempd" />
//tempList就是存放的List了
//因为是struts1,所以可以嵌套EL表达式,要不要用,你自己决定
//你希望存在session还是request你自己决定吧
</html:select>
恩,有点啰嗦,希望可以帮助到你
对了,用<html:optionsCollection />
如果你要用<html:option />也可以
但是就只能是其中一行:
例如:<html:option value="0">请选择</html:option>
最原始的:
<%
List<String> list=(List<String>)session.getAttuabte("list");
out.println("<select name='sel'>");
if(list!=null){
for(int i=0;i<lis