2016-11-09 22 views
0

は私がJSTLフォーム:C内のテーブルセルで選択:forEachの

CUSTOMERLISTは(customerGroupとassignedVendor性質を持つ)接続エンティティを保持しているリスト内のすべてのレコード/行の表のセル内のドロップダウンリストを持つようにしたい

vendorListは、ベンダーのエンティティを保持している(名前と得意先プロパティを持つ

ここでは、私がこれまで持っているものです。

<form:form action="${pageContext.request.contextPath}/vendorAdmin/viewClients/${vendorGroupID}" method="post" > 

          <table class="table table-striped table-bordered table-hover " id="sample_1"> 
           <thead> 
           <tr class="bg-success"> 

            <th>Admin Name</th> 
            <th>Email</th> 
            <th>Username</th> 
            <th>Phone</th> 
            <th>Assign To</th> 
            <th></th> 

           </tr> 
           </thead> 
           <c:forEach items="${customerList}" var="connection" varStatus="cStatus"> 
            <tr> 
             <td>${customerList[cStatus.index].customerGroup.name}</td> 

             <td class="text-center">${customerList[cStatus.index].customerGroup.customerList[0].email}</td> 
             <td class="text-center">${customerList[cStatus.index].customerGroup.customerList[0].username}</td> 
             <td class="text-center">${customerList[cStatus.index].customerGroup.customerList[0].phone}</td> 
             <td> 

              <form:select path="customerList[${cStatus.index}].assignedVendor.customerID"> 
               <form:options items="${vendorList}" itemLabel="name" itemValue="customerID"/> 
              </form:select> 

             </td> 
             <td> 
              <a href="<spring:url value="/vendorAdmin/sendMessageToCustomer/${vendorGroupID}/${customerList[cStatus.index].customerGroup.userGroupID}" />" 
              ><span class="glyphicon glyphicon-message "></span></a> 

             </td> 
            </tr> 
           </c:forEach> 
          </table> 
         </form:form> 

エラー:

ERROR o.s.web.servlet.tags.form.SelectTag - Neither BindingResult nor plain target object for bean name 'command' available as request attribute 
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute 
    at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:144) 
    at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:168) 
    at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:188) 
    at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:154) 
    at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:141) 
    at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:132) 
    at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:116) 
    at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:422) 
    at org.springframework.web.servlet.tags.form.SelectTag.writeTagContent(SelectTag.java:194) 
    at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84) 
    at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80) 

誰かが間違っていると指摘できますか?

編集:私は十分に明確でないことをお詫び申し上げます。問題は、コントローラからcustomerListを取得できないということではありません。すべて正常に動作しますform:select私はpathで間違いをしているようで、フィールドにアクセスすることはできません。これは少し明確になりますようにお願いします。

+0

にそれはコードなしでは不可能です。 –

答えて

0

Spring tablibは、入力値をバインドできるコマンド名またはモデル属性が必要です。

は、あなたがこのようなクラスがあるとしましょう -

User{ 
    private String name; 
    //Add getters setters 
} 

ページは

@RequestMapping("/form") 
public String getFormPage(Model model){ 
    model.addAttribute("user",new User()); 
} 

をロードされ、コントローラから、その後form.jsp

<form:form modelAttribute="user">/*user is set in model attribute in controller*/ 
    <form:input path="name" placeholder="Input name"> 
</form:form> 
関連する問題