我在使用 struts 2 预先选择 a 的值时遇到问题。
我使用标签 value="country"来定位 String country="Japan",并且选择从列表(字符串列表)加载元素。
但是,加载时选择仅针对列表中的第一项。
看:
<s:select list="countries" value="country" label="Conutry"
headerKey="null" name="country" id="selectCountry"
/>
public List<String> countries;
public String country;
.....
public Countries(){
countries=dao.list();
}
.........
getter and setter
........
//Action Used to get information
public getInfo(){
country="USA"
}
最佳答案
尝试:
<s:select list="countries"
value="country"
label="Conutry"
headerKey="country"
headerValue="contry"
name="countries"
id="selectCountry"/>
headerKey
表示您要发布的值。
headerValue
将显示在列表中。
关于java - 如何在选择时预先选择一个选项 (Struts 2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13349961/