<html:select name="test" id="mytest" onchange="window.location=test.do?method=show&testid=this.options[selectedIndex].value"  value="testid1">
<logic:iterate>
<html:option value=${mytest.id}>${mytest.name}</html:option>
</logic:iterate>
</html:select>

解决方案 »

  1.   

    1.你在test.do中将mytest.id赋值为0.
    2.用<html:option>
      

  2.   

    看了2位的回贴后,试了下,却没有成功。反复试验,终于测试通过了,这里通过formBean即可记住select选择的。下面我更正下我的代码:
    <html:select property="testProperty" onchange="window.location=test.do?method=show&testid=this.options[selectedIndex].value"  value="testid1">
    <html:option value=0>请选择</html:option>
    <logic:iterate id="test" name="testBean">
    <html:option value=${test.id}>${test.name}</html:option>
    </logic:iterate>
    </html:select>这里:<html:select>标签中, property属性是必须填写的,它表示了一个javabean中的某个属性,这里我将这个属性写入了formBean,并在formBean中设有相应的get/set方法。这样,在表单提交后,formBean会记住你选择的选项,并通过<html:option>来表现出来,而且<html:option>标签也必须包含在<html:select>里面,通过这个小例子关键点是<html:select>标签的属性值和javaBean的关系,搞清楚这点,就容易解决了。
    谢谢2位的提示与答复