【发布时间】:2015-02-16 15:10:31
【问题描述】:
我的 ajax 代码如下所示:
function GetProjectlist() {
alert(department);
var obj = { department : department};
$.ajax({
type: "POST",
url: "http://localhost:8080/MyApplication/getAllProjects",
data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnGetProjectSuccess,
error: OnGetProjectError
});
}
另一方面,我的控制器看起来像这样:
@RequestMapping(value = "/getAllProjects", method = RequestMethod.POST,headers = {"Content-type=application/json"})
public @ResponseBody JsonJtableProjectListResponse getAllProjects(@RequestParam(value = "department", required = false) String department) {
System.out.print("department"+department);
logger.info("Home Controller -getAllProjects");
.................................................. ...
当我在控制器中打印部门时,它为空。谁能告诉我如何将部门从 ajax 传递给控制器?
【问题讨论】:
标签: ajax spring model-view-controller