用ajax post array数组到Mvc web Api后台接受不到的问题
来源:互联网 发布:护眼手机膜 知乎 编辑:程序博客网 时间:2024/06/05 08:48
普通string数组
$.ajax({ type: "post", url: "http://localhost:8902/api/PriceRatio/Add", data: {"":["123","123","12"]}, dataType: "json", traditional: true, success: function (msg) { } });
[HttpPost] public bool Add([FromBody]string[] ids) { return true; }
对象数组:
for (var i = 0; i < 3; i++) { prices.push({ Id:"123", UpdateTime: null, Type: "other", Price: 123, Url: "www", Remark: "demo", }); }; $.ajax({ type: "post", url: "http://localhost:8902/api/PriceRatio/Add", data: { "": prices}, dataType: "json", traditional: false, success: function (msg) { } });
[HttpPost] public bool AddPriceRatios([FromBody]List<PriceRationModel> priceRations) { if (ModelState.IsValid) { return PriceRatioBLL.AddPriceRatios(priceRations) > 0; } else { throw new Exception(BadRequest(ModelState).ModelState.Values.FirstOrDefault()?.Errors.FirstOrDefault()?.ErrorMessage); } }
如果Post是string数组或者int数组,则ajax中traditional: true,
如果Post是对象数组,则ajax中traditional: false,否则对象将为空
2 0
- 用ajax post array数组到Mvc web Api后台接受不到的问题
- ajax传数组到后台Springmvc无法接受的问题
- tomcat7,ajax post参数后台获取不到的问题
- 关于jquery使用ajax传递数组到struts后台的接受问题
- axios发送post请求后台接受不到问题
- ajax传数组到后台,后台springmvc 接受数组参数
- 解决.net mvc json传值到后台,里面的值包含html标签 后台接受不到值的问题
- ajax post传递数组到后台
- ajax 后台取不到form表单post传递的值,get可以取到
- jquery post 数组参数 到 mvc api
- ajax的post请求后台request.getParameter()接收不到参数问题
- Ajax向java后台中传值为数组时,后台接收不到(为null)的问题
- Ajax向java后台中传值为数组时,后台接收不到(为null)的问题
- Spring MVC后台接收不到POST请求的参数
- Spring MVC后台接收不到POST请求的参数
- jquery ajax 传递数组 到后台收不到
- tomcat7以上,ajax post参数后台获取不到的问题,post参数大小不能大于2M的解决办法!
- thinkphp-javascript ajax上传后台 post接收不到的原因
- 数据结构-线性表
- 类的设计
- php7 连接 mysql数据库
- 高效实现Map的原子更新操作(Hystrix的InternMap<K, V>源码解析)
- rtmp complex handshake,支持h264/aac
- 用ajax post array数组到Mvc web Api后台接受不到的问题
- Content Security Policy 入门教程
- PHP学习总结(3)——PHP入门篇之PHP的echo语句
- 自定义view之仿慕课网课程学习圆形进度
- JS事件封装函数,跨浏览器添加事件和删除事件
- ASP:Gridview中的分页和选择
- 中缀表达式转换成前缀和后缀表达式这类题目的超实用解题技巧
- C++笔记
- PHP学习总结(4)——PHP入门篇之PHP计算表达式