我有以下行动形式:
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名称。列表图像只是空的。
错误可能在哪里?