Struts2下拉列表示例问题
我正在尝试使用struts2标签处理下拉列表。但到目前为止我还没有成功:下面是.jsp页面、action类、struts.xml文件和所有相关代码。任何帮助都将不胜感激。多谢各位 注意:我收到此错误:->标记“选择”,字段“列表”:请求的列表键“国家/地区”无法解析为集合/数组/映射/枚举/迭代器类型。示例:人或人。{name}-[未知位置] 。。。。。。。。。。。 Index.jsp:Struts2下拉列表示例问题,struts2,Struts2,我正在尝试使用struts2标签处理下拉列表。但到目前为止我还没有成功:下面是.jsp页面、action类、struts.xml文件和所有相关代码。任何帮助都将不胜感激。多谢各位 注意:我收到此错误:->标记“选择”,字段“列表”:请求的列表键“国家/地区”无法解析为集合/数组/映射/枚举/迭代器类型。示例:人或人。{name}-[未知位置] 。。。。。。。。。。。 Index.jsp: }在本例中,您将使用Country类作为地图。最简单的解决方案是使用适当的getter/setter创
}在本例中,您将使用Country类作为地图。最简单的解决方案是使用适当的getter/setter创建一个名为country的Hashmap属性,并用您需要的内容填充它 然后在JSP中,您可以说:
<s:select label="Country" list="country.keys">
或者你更愿意
<s:select label="Country" list="country.values">
工作流程应与上述相反。应该是
action that fills select tag(calls getcountry) -> page with form -> action(to which form will be submitted)
但在我们之上
page with form -> submitted to action that fills the select, but form has already been displayed.
private String countryAbbr;
private String countryName;
public Country() {
}
public Country(String countryAbbr, String countryName) {
this.countryAbbr = countryAbbr;
this.countryName = countryName;
}
public String getCountryName() {
return countryName;
}
public void setCountryName(String countryName) {
this.countryName = countryName;
}
public String getCountryAbbr() {
return countryAbbr;
}
public void setCountryAbbr(String countryAbbr) {
this.countryAbbr = countryAbbr;
}
<s:select label="Country" list="country.keys">
<s:select label="Country" list="country.values">
action that fills select tag(calls getcountry) -> page with form -> action(to which form will be submitted)
page with form -> submitted to action that fills the select, but form has already been displayed.