###前提・実現したいこと
現在eclipseを使ってspring,mybatisでDB連携を行っていますが、
Ajaxからpostデータを受け取ってDBと連携し送り返されたデータをjspで表示しようとしていますが、表示されません。
###発生している問題・エラーメッセージ
エラーメッセージは無く空白が表示されるのみです。
###該当のソースコード
【コントローラー】
@RequestMapping(value = "/expenseHistory", method = RequestMethod.GET)
public String expenseHistory(Locale locale, Model model) {
Integer expense_id = 9999; List<ExpenseInfo> history = expenseHistoryService.ExpenseNumber(expense_id); model.addAttribute("history", history); return "expenseHistory"; } @RequestMapping(value = "/ExpenseSearch", method = RequestMethod.POST) public String ExpenseSearch(Locale locale, Model model,@RequestParam String month, String year) { Integer expense_id = 9999; HashMap map = new HashMap(); map.put("expense_id",expense_id); map.put("month",month); map.put("year",year); List<ExpenseInfo> result = expenseHistoryService.ExpenseSearch(map); model.addAttribute("result", result); return "expenseHistory"; }
【Ajax】
<script> function search(){ var month = $("#select_number").val(); var year = $("#select_year").val(); $.ajax({ url:'ExpenseSearch', data:{ month:month, year:year }, type : 'post', cache : false, success : function(data){ if(data){ //コントローラーに送信 window.location.reload(); }else{ alert("miss"); } } }); } </script>【jsp】
<c:forEach items="${modosu}" var="modosu">
<tr>
<!-- 日付 -->
<td><c:out value="${modosu.expenseDate}"></c:out></td>
<!-- 内容 -->
<td><c:out value="${modosu.expenseContents}"></c:out></td>
<!-- 往復 -->
<td></td>
<!-- 画像 -->
<td><a href="#" class="view-link">View</a></td>
<!-- 料金 -->
<td style="text-align:right;">¥<c:out value="${modosu.expenseCost}"></c:out></td>
</tr>
</c:forEach>
###試したこと
SQLから該当のデータが受け取れていることは確認できていますが、リターンの仕方が悪いのかと思っていますが、解決策がみつかりません。
###補足情報(言語/FW/ツール等のバージョンなど)
eclipse4.5
spring3.7.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/18 04:56
2016/10/18 05:05