2015-07-20 35 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'中設置 –

相關問題