我有一个文本输入和一个Thymeleaf HTML文件中的按钮:
<input type="number"/>
<btn><a th:href="@{/filter/{minimumAmount}}">Search</a></btn>
我想从输入中传递Integer值,然后在单击Button后将其传递给控制器。在输入中我如何引用&#34; minimumAmount&#34;以便可以将值发送到控制器,该控制器将获取该值并使用它来运行某些自定义查询?
这是我的控制器代码:
@RequestMapping("/filter/{minimum}")
public String customList(Model model, @PathVariable int minimum){
int total = expService.calculateTotalExpense(expenseRepo.customQuery(minimum));
model.addAttribute("expenselist", expenseRepo.customQuery(minimum));
model.addAttribute("totalExpense", total);
return "expense";
}
答案 0 :(得分:0)
试试这个
HTML
$('#search').unbind("click");
$('#search').bind("click",function(){
var amount = $('#number').val();
var minAmount = $('#minAmount').val();
if(amount ===0){
amount = minAmount;
}
$.ajax({
url: "filter/"+amount ,
type: "get", //send it through get method,
success: function(response) {
//Do Something
},
error: function(xhr) {
//Do Something to handle error
}
});
});
的jQuery
self.selectedDepartment = ko.observable(undefined);