对于jsp页面中导入的组件,不会填充传递的modelAttributes

时间:2019-05-07 05:16:02

标签: spring jsp jstl

在我看来,我正在基于从Spring控制器传递的布尔值导入jsp组件。还会从控制器传递一个对象列表,这些对象应填充导入组件中的字段。

控制器:

   List<LeadUser> leadUsersList = null;
        leadUsersList = businessApiClient.getUsersBySignUpType(type, id);
        if (leadUsersList != null || leadUsersList.size() != 0) {
            model.addAttribute("leadUsersList", leadUsersList);
            model.addAttribute("displayTable", true);
            if("webinars".equals(type)){
                model.addAttribute("displayWebinarTable", true);
            } else if("events".equals(type)){
                model.addAttribute("displayEventTable", true);
            } else if("info".equals(type)){
                model.addAttribute("displayInfoTable", true);
            } else if("booklets".equals(type)){
                model.addAttribute("displayBookletTable", true);
            }

视图:

 <c:when test="${displayTable}">
    <div class="tab-content">
        <div class="tab-pane fade in active">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-11 col-md-offset-1">
                        <div class="page-card">
                            <div class="page-card__body">
                                <c:choose>
                                    <c:when test="${displayBookletTable}">
                                            <jsp:include page="components/report-table-comopnents/booklet_signup.jsp" />
                                    </c:when>
                                    <c:when test="${displayEventTable}">
                                        <jsp:include page="components/report-table-comopnents/event_signup.jsp" />
                                    </c:when>
                                    <c:when test="${displayInfoTable}">
                                        <jsp:include page="components/report-table-comopnents/info_signup.jsp" />
                                    </c:when>
                                    <c:when test="${displayWebinarTable}">
                                        <jsp:include page="components/report-table-comopnents/webinar_signup.jsp" />
                                    </c:when>
                                </c:choose>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</c:when>

导入表组件:

booklet_signup.jsp(其他三个也与此类似):

<div class="table-responsive">
  <table id="bookletLeadsTable"
     class="table table-bordered table-striped dataTable">
 <thead>
  <tr>
   <th>Email</th>
   <th>Business Name</th>
   <th>Contact Name</th>
   <th>Phone Number</th>
   <th>Ref Page</th>
   <th>Created Date & Time</th>
 </tr>
 </thead>
 <tbody>
    <c:forEach items="${leadUsersList}" var="item">
      <tr>
       <td>${item.email}</td>
       <td>${item.businessName}</td>
       <td>${item.contactName}</td>
       <td>${item.phoneNo}</td>
       <td>${item.refPage}</td>
       <td>${item.createdTime}</td>
      </tr>
     </c:forEach>
   </tbody>
  </table>
 </div>

<script type="text/javascript">
  $(document).ready(function () {
   $('#bookletLeadsTable').DataTable({
    "paging": false,
    "info": false
    })
  });
</script>

现在,问题ID不会由modelAttribute leadUsersList填充导入组件(booklet_signup.jsp)中的jstl标签。当它没有被插入并停留在主视图中时,它会变得很好。这里可能出了什么问题?

0 个答案:

没有答案