jsp页面
//提交多个json
$('#submitJsonzMore').click(function(){
var json="{pet:{petId:1,petName:'doudou'},food:{foodId:2,foodName:'香蕉'}}";
$.ajax({
url:'${ctx}/testMvc/adaptor/testPairAdaptorJsonMore',
//JavaScript 值转换为 JSON 字符串
data:JSON.stringify(json),
type:'post',
dataType:'json',
cache:false,
success:function(data){
console.log(data);
},
error:function(data){
}
})
});
module代码
@At
@Ok("json")
//JSON 输入流 - JsonAdaptor
//json传递多个对象
@AdaptBy(type=JsonAdaptor.class)
public NutMap testPairAdaptorJsonMore(@Param("pet") Pet pet,@Param("food") Food food){
log.info("JsonAdaptor");
log.info("petId:"+pet.getPetId());
log.info("petName:"+pet.getPetName());
log.info("---");
log.info("foodId:"+food.getFoodId());
log.info("foodName:"+food.getFoodName());
return NutMap.NEW().addv("pet",pet).addv("food", food);
}
错误代码:
2018-02-14 12:33:30 [http-nio-8080-exec-8] INFO cc.myspring.nutz.admin.module.TestMvcAdaptor - JsonAdaptor
2018-02-14 12:33:30 [http-nio-8080-exec-8] INFO cc.myspring.nutz.admin.module.TestMvcAdaptor - petId:0
2018-02-14 12:33:30 [http-nio-8080-exec-8] INFO cc.myspring.nutz.admin.module.TestMvcAdaptor - petName:null
2018-02-14 12:33:30 [http-nio-8080-exec-8] INFO cc.myspring.nutz.admin.module.TestMvcAdaptor - ---
2018-02-14 12:33:30 [http-nio-8080-exec-8] INFO cc.myspring.nutz.admin.module.TestMvcAdaptor - foodId:0
2018-02-14 12:33:30 [http-nio-8080-exec-8] INFO cc.myspring.nutz.admin.module.TestMvcAdaptor - foodName:null
是字符串格式不对吗 应该怎么写?