当我尝试在服务器上检索verifyCodeActual
参数时,结果为null
。
String code = request.getParameter("verifyCodeActual"); // This is null
但是我可以在Chrome控制台数据中看到这个参数在正文中发布:
the chrome console (data form)
以下是服务器端java代码的相关部分:
Relevant part of the server-side java code
这是JS ajax查询:
var formData = new FormData();
var verifyCodeActual = $('#j_captcha').val();
formData.append("verifyCodeActual", verifyCodeActual);
$.ajax({
url : (isEdit ? editShopUrl : registerShopUrl),
type : 'POST',
data : formData,
contentType: "application/x-www-form-urlencoded",
cache: false,
processData: false,
success ...
}
});
答案 0 :(得分:0)
这会对你有所帮助
$.ajax({
url : (isEdit ? editShopUrl : registerShopUrl),
type : 'POST',
data : {
verifyCodeActual : $('#j_captcha').val()
},
contentType: "application/x-www-form-urlencoded",
cache: false,
processData: false,
success ...
}
});
@RequestMapping(value = "/modifyshop", method = RequestMethod.POST)
public @ResponseBody Map<String, Object> modifyShop(@RequestBody Object verifyCodeActual) throws Exception {
System.out.println(verifyCodeActual);
}