【发布时间】:2014-08-14 11:54:34
【问题描述】:
在我的 spring 项目中,我通过 Ajax 调用发送请求,如下所示:
function doAjaxPost(currentPage) {
var appName = document.searchForm.txtZipFile.value;
var e = document.getElementById("selectStatus");
var appStatus = e.options[e.selectedIndex].text;
$.ajax({
type : "GET",
url : "http://localhost:8080/ preListOnSearch.do",
data : "currentPage=" + currentPage + "&appName=" + appName + "&appStatus="
+ appStatus,
cache: false,
success : function(response) {
alert(response);
},
error : function(e) {
alert('Error: ' + e);
}
});
}
在我的控制器中,我编写了如下方法:
@RequestMapping(value = "/preListOnSearch", method=RequestMethod.GET)
public String preTestDataolx(@PathVariable("siteId") String siteId, @PathVariable(value = "currentPage") String currentPage,
@RequestParam(value = "appStatus") String appStatus) {
System.out.println(appStatus);
return "/preTestData";
}
但这给了我错误。当我从方法定义中删除 RequestParams 时,它工作正常。所以我只想知道如何访问控制器中的ajax调用参数。
【问题讨论】:
-
它工作正常,没有错误
标签: java ajax spring jakarta-ee spring-mvc