问题一:springboot
后端接受 前端传json
数组
前端
var data = {
"arr": ["DeliverID:1000,CK00000021"]
}
$.ajax({
type : "post",
url : "/bloomberg/save",
data : data,
contentType: 'application/json',
success : function (result) {
console.log(result);
}
})
后端接受到话我一开始写的是
但是会报错,显示json
解析异常
正确的做法是
@PostMapping("/deleteByGoodIds")
@ApiOperation(value="根据商品id删除汇总表DeliverGoodsSum和扫描表DeliverGoodsScan数据")
public Result<Boolean> deleteByGoodIds(@RequestBody JSONObject jsonObject) {
JSONArray jsonArr = jsonObject.getJSONArray("arr");
// 处理
}
问题二
传递form
表单和json
form
@PostMapping("/selectByGoodsIdOrCaseNo")
@ApiOperation(value="根据id和箱号分页查询")
public Result<Page> selectByGoodsIdOrCaseNo(@RequestParam Map<String, Object> params) {
params.get("limit");
}
json
@PostMapping("/selectByGoodsIdOrCaseNo")
public Result<Boolean> add(@RequestBody User user){
user.getAddress();
}
同时传递form
和json
@PostMapping("/selectByGoodsIdOrCaseNo")
@ApiOperation(value="根据id和箱号分页查询")
public Result<Page> selectByGoodsIdOrCaseNo(@RequestParam Map<String, Object> params,User user) {
}