0
<s:select name="country" list="countryList" listKey="countryId"
listValue="countryName" headerKey="0" headerValue="Country"
label="Select a country" />
country.java地圖作用在支柱2
package vaannila;
public class Country {
private int countryId;
private String countryName;
Country(int countryId, String countryName) {
this.countryId = countryId;
this.countryName = countryName;
}
public int getCountryId() {
return countryId;
}
public void setCountryId(int countryId) {
this.countryId = countryId;
}
public String getCountryName() {
return countryName;
}
public void setCountryName(String countryName) {
this.countryName = countryName;
}
}
HelloWorld.java
public class HelloWorld {
private String message;
private String userName;
private String gender;
private boolean language;
private ArrayList<Country> countryList;
public HelloWorld(){
countryList = new ArrayList<Country>();
countryList.add(new Country(1, "India"));
countryList.add(new Country(2, "USA"));
countryList.add(new Country(3, "France"));
}
public boolean isLanguage() {
return language;
}
public void setLanguage(boolean language) {
this.language = language;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public ArrayList<Country> getCountryList() {
return countryList;
}
public void setCountryList(ArrayList<Country> countryList) {
this.countryList = countryList;
}
public String execute() {
setMessage("Hello " + getUserName());
return "SUCCESS";
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
struts.xml中
<struts>
<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
<action name="HelloWorld" class="vaannila.HelloWorld">
<result name="SUCCESS">/success.jsp</result>
</action>
</package>
</struts>
HTTP狀態500
org.apache.jasper.JasperException:標記'select',字段'list',名稱'country':請求的列表鍵'countryList'無法解析爲集合/數組
這是錯誤提交。 誰能幫助我
我的理解是,你從列表中選擇國家,而submittimg你收到此例外(糾正我,如果情況並非如此)。您尚未提到要填充要提交列表的頁面的操作映射。 – anu 2011-06-14 11:20:59
沒有我的網頁沒有運行 – coder 2011-06-14 19:29:06
您沒有清除我。哪個操作不起作用,填充列表或其他提交它的那個?我還需要看到其他操作映射 – anu 2011-06-15 06:05:33