zoukankan      html  css  js  c++  java
  • 解决:vue表单数据后台拿不到值问题

    问题:vue前端表单数据post提交之后,后台controller拿不到值

    前言:今天做多条件查询提交表单之后,发现后台拿不到值,在后端controller加上@RequestBody还是拿不到,最后,使用qs完美解决了问题

    项目环境:springboot+vue前后端分离

    代码贴出来供参考:

    重点在于:

    var qs = require('querystring')

    qs.stringify(this.formInline)

    vue-page

    /*多条件查询方法*/
    onsubmit(formName) {
        const _this = this
            this.$refs[formName].validate((valid) => {
            if (valid) {
                var qs = require('querystring')
                    axios.post("http://localhost:8181/Task/getMoreAllTasks/1/4/",  qs.stringify(this.formInline)
                              ).then(function (resp) {
                    _this.tableData = resp.data.list
                        _this.total = resp.data.total
                });
            } else {
                return false;
            }
        });
    },
    

    controller层

    //多条件查询任务信息
    @PostMapping("/getMoreAllTasks/{page}/{size}")
    public PageInfo<Task> getAllTasks(@RequestBody @PathVariable("page") int pageNo, @PathVariable("size") int pageSize, String taskTitle, String taskState, String taskBuilder, String startTime, String endTime) {
        PageHelper.startPage(pageNo, pageSize);
        //执行查询所有部门方法
        List<Task> allTasks = taskService.getAllTask(taskTitle, taskState, taskBuilder, startTime, endTime);
        PageInfo<Task> interPageInfo = new PageInfo<Task>(allTasks);
        return interPageInfo;
    }
    

    至此,问题就解决了

  • 相关阅读:
    总结ORACLE学习8023
    set @CurrentID=@@IDENTITY
    一个IT人:跳槽一定要谨慎
    SQL Server数据库开发(转自CSDN)
    46个不得不知的生活小常识
    CodeProjectSome Cool Tips For .Net 之一
    数据库原理综合习题答案
    EDM
    CodeProject Some Cool Tips for .NET之二
    The operation is not valid for the state of the transaction.
  • 原文地址:https://www.cnblogs.com/dreamzone/p/13080843.html
Copyright © 2011-2022 走看看