【问题标题】:List in struts form does not get updatedstruts形式的列表没有得到更新
【发布时间】:2013-06-25 11:07:17
【问题描述】:

我有以下行动形式:

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>();
}
}

在一个动作中,我为 images 列表预加载了一些值,在 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 name 设置正确。 images 列表是空的。

错误可能在哪里?

【问题讨论】:

  • 没有indexed 属性或类似的东西吗?

标签: forms list struts-1


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2013-08-12
    • 1970-01-01
    • 1970-01-01
    • 2016-09-16
    • 1970-01-01
    • 1970-01-01
    • 2013-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多