ajax请求发送json数据
前端代码
function submitHandler() {
var data3 = {
"enCode": 100,
"enName": "2123",
"flueNum": 2,
"pipes": [
{
"name": "123"
},
{
"name": "124"
}]
};
var data4=JSON.stringify(data3);
if ($.validate.form()) {
//新增
$.ajax({
url: prefix + "/add",
type: "post",
dataType: "json",
contentType : 'application/json;charset=utf-8',
data: data4,
success: function (result) {
},
error: {}
});
}
}
后台接收
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@RequestBody Enter enter, HttpServletRequest request)
{
return toAjax(1);
}
实体类
public class Enter extends BaseEntity { private static final long serialVersionUID = 1L; /** null */ private Long id; /** 编码 */ @Excel(name = "编码") private Long enCode; /** 名称 */ @Excel(name = "名称") private String enName; private List<Pipe> pipes; ………… }