日期:2014-05-18  浏览次数:20634 次

struts高手请教!!!
在jsp页面中   从数据库取出记录并在页面用html:select标签(下拉列表框)显示出来   怎样在action中把用户选择的选项文本取出来   对应的actionForm又怎么做呢

------解决方案--------------------
和html:text一样
------解决方案--------------------
<html:select property= "Name " name= "**Form ">
<html:options collection= "list " property= "userName " labelProperty= "userName "/>
</html:select>


Name:你这个下拉框的名字
**Form:下拉框值对应的Form
list:Action中取到的值(数组,ArrayList...)
userName:Form中对应的
------解决方案--------------------
<html:select property= "1 "> 再你对应的ACTIONFORM中要有相应的set1()、get1()方法
------解决方案--------------------
首先在Action里查询得到数据Bean(假设类User属性name)放入List变量list然后存入request里

然后在jsp页面的form中XXX属性设置
<html:select property= "XXX ">
<html:options collection= "list " property= "user " labelProperty= "name "/>
</html:select>
//注:
collection指定request中放的数据列表
property指定数据列表中放的数据bean对象名称
labelProperty指定数据列表中放的数据bean对象属性
------解决方案--------------------
<html:select property= "chargeID " styleClass= "text ">
<logic:present name= "explainList ">
<html:options collection= "explainList " property= "chargeID " abelProperty= "explain " />
</logic:present>
</html:select>

explainList: action中得到的集合
form 中有 <html:select property= "chargeID " ...的chargeID的get set方法。。
你先自己写一些,看出什么错,大家再帮你看。。


------解决方案--------------------
几位高手说的各不相同啊~ 能再详细点么 最好有个小例子
------解决方案--------------------
关注