【问题标题】:Struts 1.2: html:options does not find a collection from a beanStruts 1.2:html:options 找不到来自 bean 的集合
【发布时间】:2013-05-30 21:07:03
【问题描述】:

我有一个 Struts 页面,它在我的 JSP 中以表单形式显示以下内容:

            <html:select property="value">
                <html:options collection="valueNext"/> 
            </html:select>

在 Java 形式中,getter 都存在:

    public AValue getValue() {
        return value;
    }

    public List<AValue> getValueNext() {
        return value.next();
    }

然而,当我尝试显示页面时,我总是收到一条错误消息,告诉我以下内容:

在名称 value 下找不到 bean 下一个

我不明白为什么 Struts 会找到 value 而不是 valueNext(是的,我已经删除了 html:options 行,它可以工作)。

我对 Struts 很陌生,但在我看来,两者都在同一个范围内。有人可以启发我吗?

【问题讨论】:

    标签: java jsp struts


    【解决方案1】:

    我终于找到了(感谢另一位贡献者的帮助)。

    我没有使用正确的标签:html:options 是在您调用另一个 bean 时使用。

    要调用表单的属性,我应该改用html:optionsCollection。以下 JSP 工作正常:

            <html:select property="value">
                <html:optionsCollection property="valueNext"/> 
            </html:select>
    

    (Struts 文档:html:optionshtml:optionsCollection

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-15
      • 2012-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-19
      • 2011-05-21
      相关资源
      最近更新 更多