0

key=catId および value=catName のボックスを選択するために、arrayList タイプの catList オブジェクトを設定したい

public class GamesAction extends ActionSupport {
 private ArrayList catList;

 public String populate() {
    GamesCategoryBusiness gcb = new GamesCategoryBusiness();
    Map data = gcb.fetchAll();//fetching games category from database
    String status = (String) data.get("status");
    if (status.equalsIgnoreCase("success")) {
        setCatList((ArrayList) data.get("gameCatList"));
        return "POPULATE";
    } else {
        addActionError("Not able to fetch Game categories");
        return INPUT;
    }



 public ArrayList getCatList() {
    return catList;
}

public void setCatList(ArrayList catList) {
    this.catList = catList;
}

}

別のクラス

 public class GamesCategoryAction extends ActionSupport {

private long catId;
private String catName;

public long getCatId() {
    return catId;
}

public void setCatId(long catId) {
    this.catId = catId;
}

public String getCatName() {
    return catName;
}

public void setCatName(String catName) {
    this.catName = catName;
}

struts.xml 内

 <action name="gameCatAdded" class="GamesCategoryAction"
            method="addCategory">
        <result name="POPULATE">/allCategory.jsp</result>
        <result name="success">/allCategory.jsp</result>
        <result name="input">/addCategory.jsp</result>
        <result name="login">/login.jsp</result>
    </action>

Jspで

 <s:select list="catList"
                     listKey="catId"
                     listValue="catName"
                     name="gamesCategoryId"
                     label="Category"
                     labelposition="top"/>

jspページでは、次のエラー例外が表示されています

org.apache.jasper.JasperException: tag 'select', field 'list', name 'gamesCategoryId':    The requested list key 'catList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
       org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:584)
4

1 に答える 1

0

これを試してください:ArrayList<Catalog> catListアクションクラスで。オブジェクト型を宣言していない場合、オブジェクト型は不明です。(とCatalogを含むというドメイン クラスがあると仮定します)catIdcatName

于 2012-09-21T20:39:08.353 に答える