Ajax
$.ajax({
url:"http://localhost:8080/room/insertHotelCollectionByHotelId",
contentType:"application/json;charset=UTF-8",
data:'"hotelCollectionId":"6","hotelId":"3","userId":"3"',
//注意:上面的data数据缺少{},后台无法解析
dataType:"json",
type:"post"
})
原接口
@RequestMapping("insertHotelCollectionByHotelId")
public void insertHotelCollectionByHotelId(@RequestBody String body) throws IOException {
System.out.println("insertHotelCollectionByHotelId............");
System.out.println(body);
}
解决办法:添加@ResponseBody
@ResponseBody
@RequestMapping("insertHotelCollectionByHotelId")
public void insertHotelCollectionByHotelId(@RequestBody String body) throws IOException {
System.out.println("insertHotelCollectionByHotelId............");
System.out.println(body);
}
注意
转载:https://blog.csdn.net/qq_36436290/article/details/101035050
查看评论