<p>前端javascript发起post请求:</p>
<pre><code class="language-javascript">var data = {
  list: [obj1, obj2, obj3],
  bizID: '123456'
};

fetch('/api/service', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(data)
})
.then(function(response) {
  return response.json();
})
.then(function(result) {
  console.log(result);
});
</code></pre>
<p>Java端提供服务参数为List<Object>和bizID:</p>
<pre><code class="language-java">@PostMapping(&quot;/api/service&quot;)
public ResultDTO service(@RequestBody Map&lt;String, Object&gt; params) {
  List&lt;Object&gt; list = (List&lt;Object&gt;) params.get(&quot;list&quot;);
  String bizID = (String) params.get(&quot;bizID&quot;);

  // do something with list and bizID

  return new ResultDTO();
}
``
</code></pre>
前端javascript发起post请求java端提供服务参数分别为ListObject和bizID请分别给出两端代码

原文地址: http://www.cveoy.top/t/topic/cRmY 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录