当前位置:   article > 正文

前端传id集合,后端接收_前端传一个id后端怎么接受

前端传一个id后端怎么接受

 一.前端

  1. //批量申报
  2. DeclarationFn: function () {
  3. let selected = this.$refs.dataTable.getSelectedRows();
  4. if (!selected || selected.length == 0) {
  5. this.$warning("请选择需要申报的单证!");
  6. return;
  7. }
  8. var map = selected.map((item) => item.state);
  9. if (map.includes(1)) {
  10. this.$warning("请选择需要未上报的单证!");
  11. return;
  12. }
  13. this.$showConfrim({
  14. content: "此操作将永久性删除数据,是否继续?"
  15. }).then(() => {
  16. customsService.declareSelected(selected.map((item) => item.id)).then((res) => {
  17. if (res.status) {
  18. this.$success("申报成功!");
  19. this.search();
  20. } else {
  21. this.$warning(res.msg ? res.msg : "申报失败");
  22. }
  23. });
  24. });
  25. },
  1. customsService.declareSelected = function (idList) {
  2. return new Promise((resolve, reject) => {
  3. api.post("/kzy-customs/declare?idList="+idList, null).then(response => {
  4. var result = {};
  5. result.status = response.code == "200";
  6. result.msg = response.msg;
  7. resolve(result);
  8. }).catch(err => {
  9. reject(err);
  10. })
  11. });
  12. }

 1.1前端传入格式

 前端传的数据格式为:

 

二.后端代码

  1. //方法一直接使用List<String>接收 前端会自动转义为集合
  2. @PostMapping("/declare")
  3. public OutputBean declare(@RequestParam List<String> idList) {
  4. }
  5. //方法二使用String接收
  6. @PostMapping("/declare")
  7. public OutputBean declare(@RequestParam String idList) {
  8. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/280060
推荐阅读
相关标签
  

闽ICP备14008679号