1

我有以下行动形式:

public class ImageGalleryActionForm extends org.apache.struts.action.ActionForm {
    private String name;
    private List<GalleryImage> images; 
    //GalleryImage is just a class with name and description as strings (and get/set methods)
    public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public List<GalleryImage> getImages() {
    return images;
}

public void setImages(List<GalleryImage> images) {
    this.images = images;
}

public ImageGalleryActionForm() {
    this.name = "";
    this.images = new ArrayList<GalleryImage>();
}

@Override
public void reset(ActionMapping mapping,HttpServletRequest request){
    name = "";
    images = new ArrayList<GalleryImage>();
}
}

在一个动作中,我预加载了图像列表的一些值,在 JSP 中,我显示了这些值并允许用户更改图像的描述和画廊的名称:

<html:form action="/pages/createNewGalleryAction" method="
    Gallery name: <html:text property="name" />
    <logic:iterate id="images" name="ImageGalleryActionForm" property="images">
         Image name: <bean:write name="images" property="name"/>
         Description:<br/>
         <html:textarea name="images" property="description" />
    </logic:iterate>
    <html:submit>Submit</html:submit>
</html:form>

这按预期显示,但是当下一个操作收到表单时,它只正确设置了 ImageGalleryActionForm名称。列表图像只是空的。

错误可能在哪里?

4

1 回答 1

1

因为使用了不同的关键字,所以没有早点找到这个。问题在这里得到解答:Struts logic:iterate input field

于 2013-06-25T13:06:15.080 回答