2015-07-20 68 views
0

HTML页面显示搜索结果。点击Mass update按钮,我需要将搜索结果(searchList)传递给控制器​​。任何人都可以帮助如何将整个搜索结果传递给控制器​​?结果是类型List<Map<String, Object>>如何将搜索结果传递到控制器

HTML代码:

<div id="resultstabJoin" th:if="!${#lists.isEmpty(searchList)}"> 
    <table class="tg" id="results" style="width: 100%"> 
     <thead> 
      <tr> 
       <th class="">Person #</th> 
       <th class="">Creator</th> 
       <th class="">Valid From</th> 
       <th class="">Valid To</th> 
       <th class="">Effective From</th> 
       <th class="">Expiry</th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr th:each="map : ${searchList}"> 
       <td class="tg bg"><a th:id="${map['PERSON_ID']}" style="cursor: pointer;" 
        th:text="${map['PERSON_ID']}"         
        th:onclick="'javascript:viewActionURL(\'' + @{../searchController/__${map['PERSON_ID']}__} + '\')'"></a></td> 
       <td class="tg bg" th:text="${map['CREATED_BY']}"></td> 
       <td class="tg bg" th:text="${map['VALID_FROM']}"></td> 
       <td class="tg bg" th:text="${map['VALID_TO']}"></td> 
       <td class="tg bg" th:text="${map['COMMENCEMENT_DT']}"></td> 
       <td class="tg bg" th:text="${map['EXPIRY_DT']}"></td> 
      </tr> 
     </tbody> 
    </table> 
    <div class="row" align="right" style="width: 100%; margin-top: 10px;"> 
     <input type="button" value="Mass Update" class="btn btn-primary" id="massUpdate" th:onclick="'javascript:muActionURL(\'' + @{/searchController/massUpdate} + '\')'"/> 
    </div> 
</div> 

回答

1
  1. 转换searchlist到JSON:VAR = searchListJson JSON.stringify(searchList)
  2. 当用户点击更新按钮,提交一个表单其中searchListJson设置为隐藏输入字段
0

由于您的搜索结果似乎来自与群发更新按钮进行交互的相同应用程序,你不需要请求数据然后推回去。使用与您的搜索结果相同的查找策略,只需发出触发服务器更新的请求即可。这避免了不必要地来回发送潜在的大数据集。

+0

Thankyou的答复。对不起。我不明白。我可以请你详细解释一下。谢谢。 –

+0

问题是,搜索结果将显示在搜索按钮上。但稍后,当点击大量更新按钮时,搜索结果将消失。我需要保留结果表。根据代码,搜索按钮操作进入到控制器的'/ search'映射,并且批量更新按钮单击重定向到控制器的'/ massupdate'映射。结果实际上是从DB中提取的,并在modelAttribute中设置,它是句柄,并在'/ search'中设置 –

相关问题