传参方式是request payload,参数格式是json,而并非用的是form传参,所以在后台用接收form数据的方式接收参数就接收不到了。
POST表单请求提交时,使用的Content-Type是application/x-www-form-urlencoded,而使用原生AJAX的POST请求如果不指
定请求头RequestHeader,默认使用的Content-Type是text/plain;charset=UTF-8,而此处的Content-Type是:
解决办法:
//要通过post传递的参数 var data = { pageindex: 1, pagesize: 8, }, //post请求的地址 url = "/admin/KeyValue/GetListByPage", //将参数传递的方式改成form postCfg = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: function (data) {//transformRequest是用来转换请求参数的数据格式,data为参数对象 return $.param(data); } }; //发送post请求,获取数据 $http.post(url, data, postCfg) .success(function (response) { alert("aa"); });
现在传参方式就变成form方式了,然后后端就可以正常接收参数了!
</div>
<div class="itemdesc">
posted on <span id="post-date">2017-01-17 20:34</span> <a href="https://www.cnblogs.com/litter/">勤奋的litter</a> 阅读(<span id="post_view_count">3041</span>) 评论(<span id="post_comment_count">0</span>) <a href="https://i.cnblogs.com/EditPosts.aspx?postid=6294488" rel="nofollow">编辑</a> <a href="#" onclick="AddToWz(6294488);return false;">收藏</a>
</div>
</div>
<div class="seperator"> </div>
<script type="text/javascript">var allowComments=true,cb_blogId=313635,cb_entryId=6294488,cb_blogApp=currentBlogApp,cb_blogUserGuid='6c48869e-3f9b-e611-845c-ac853d9f53ac',cb_entryCreatedDate='2017/1/17 20:34:00';loadViewCount(cb_entryId);var cb_postType=1;</script>