【Vue】axios发送请求

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping
public class UpdateTimeController {
 
@Autowired
TimeMapper timeMapper;
 
public String queryEndTime(@RequestBody String id){//传入后端为json对象{"id":"12345678"}
TimeDO timeBean = JSON.parseObject(id,TimeDO.class);<br>TimeDO  time = TimeMapper.getTimeByReqId(timeBean.getId());
return JSON.toJSONString(time);}
}

 

public class TimeDo {
    private String id;
    private String endTime;
 
    public String getId() {
        return id;
    }
 
    public void setId(String id) {
        this.id = id;
    }
 
    public String getEndTime() {
        return endTime;
    }
 
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
}

  

new Vue({
    el:'#app',
    data(){
        return{
            time:{
                id:'',
                endTime:''
            }
        }
    },
    methods:{
        queryEndTime:function(){
            axios({
                url:'/queryEndTime',
                method:'post',
                data:{
                    id:this.time.id  //输入框输入的id值
                }
            }).then(response=>{
                this.time = response.data;
                console.log(this.time.endTime);
            });
 
        }
    }
 
});

  

 

 

requestId
posted @   iTao0128  阅读(155)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示