springboot 接收参数 对象中包含对象List

前端 ajax提交   设置 contentType:"application/json"

提交格式

{
	"buyer_email": "[email protected]",
        "buyer_name": "lzs",
	"buyer_mobile": "123456789",
	"passengers": [{
		"create_time": "2019-04-24 14:56:30",
		"passport": "b1234888",
		"user_id": 1,
		"mobile": "17888888888",
		"name": "李xx",
		"id": 1,
		"identity_card": "370403xxxx8888"
	}, {
		"create_time": "2019-04-24 14:56:30",
		"passport": "b1234222",
		"user_id": 1,
		"mobile": "17222222222",
		"name": "徐xx",
		"id": 3,
		"identity_card": "370403xxxx3333"
	}, {
		"create_time": "2019-04-24 14:56:30",
		"passport": "b1234111",
		"user_id": 1,
		"mobile": "17111111111",
		"name": "张xx",
		"id": 2,
		"identity_card": "370403xxxx2222"
	}]
	
}

controller

@ResponseBody
	@RequestMapping(value="/order/user/{user_id}", method=RequestMethod.POST)
	public StatusResult SaveOrder(@PathVariable Integer user_id, @RequestBody App_order order) {
		
		System.out.println(JSONObject.toJSON(order));
		return StatusResult.ok();
	}

entity

public class App_order implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;


    /**
     *联系人姓名
     */
    @TableField("buyer_name")
    private String buyer_name;

    /**
     * 实付电话
     */
    @TableField("buyer_mobile")
    private String buyer_mobile;
    
    /**
     * 联系人邮箱
     */
    @TableField("buyer_email")
    private String buyer_email;
    
   
    
    @TableField(exist=false)
    private List passengers;


}

 

你可能感兴趣的:(springboot)