我就用SpringMVC的工作,我從阿賈克斯將數據傳遞給控制器,但是我在我的控制器空值,請檢查下面如何將json對象從ajax傳遞到spring mvc控制器?
function searchText()
{
var sendData = {
"pName" : "bhanu",
"lName" :"prasad"
}
$.ajax({
type: "POST",
url: "/gDirecotry/ajax/searchUserProfiles.htm,
async: true,
data:sendData,
success :function(result)
{
}
}
MyControllerCode我的代碼
RequestMapping(value="/gDirecotry/ajax/searchUserProfiles.htm",method=RequestMethod.POST)
public @ResponseBody String getSearchUserProfiles(HttpServletRequest request)
{
String pName = request.getParameter("pName");
//here I got null value
}
任何一個可以幫助我
什麼是/ gDirecotry?它是否在'WEB-INF'文件夾下? –