JSTL html选择和选项:无法在名称下找到bean

时间:2014-12-17 17:54:58

标签: java jsp jstl javabeans

我有这些对象的集合:

public class MyForm
{
    private List<Selection> selections = new ArrayList<Selection>();

    ... getters / setters ...
}

public class Selection
{
    private Option option;
    private List<Option> options = new ArrayList<Option>();

    ... getters /setters ...
}

public class Option
{
    private Integer id;      
    private Integer aValue;
    private Integer anotherValue;
    private Integer choiceIdentifier;

    ... getters /setters ...
}

在我的JSP中,我这样做:

<c:forEach var="selection" items="${selections}">

    ... numerous uses of selection that work fine ...

    <html:select name="selection" property="option" 
        indexed="true" styleId="option_${selection.option.id}"
        title="Option" styleClass="reasonsel" 
        disabled="false" >
        <html:options collection="${selection.options}" property="choiceIdentifier" labelProperty="description"/>
    </html:select>
</c:forEach>

我得到了:

javax.servlet.jsp.JspException: Cannot find bean under name [Option[id=null, aValue=5678, anotherValue=1234, choiceIdentifier=1212]]

很抱歉提出这么多问题

编辑:使用Option bean更新 编辑:使用表单bean

更新

1 个答案:

答案 0 :(得分:0)

MyForm是你的jsp的bean。

因此,JSP页面中的所有html标记property都应该在您的表单中。

<html:select name="selection" property="option"

但您的表单页面中没有选项。