混合使用@RequestBody()和@RequestParam()
RequestParam参数放在前端ajax的url后用?连接,
RequestBody参数则是正常放在data中以json字符串形式传
var user = eval("("+sessionStorage.getItem("user")+")");
$.ajax({
url: "${pageContext.request.contextPath}/user/getMail?mailNum="+sessionStorage.getItem("mailNum"),
method: "post",
data: JSON.stringify(user),
datatype: "json",
contentType: "application/json",
xhrFields: {withCredentials: true},//提供cookie信息
// success: function (res) {
//
// }
});
//-----------------------------------后端代码
@RequestMapping("/getMail")
@ResponseBody
public HashMap<String,Object> getMail(@RequestBody() User user,@RequestParam("mailNum") Integer mailNum){
HashMap<String,Object> map = new HashMap<String, Object>();
System.out.println(mailNum);
return map;
}