Vue中用axios向后端接口POST数据,Spring端收不到

本文讨论了Vue中使用axios向后端Spring接口POST数据时遇到的问题,Spring端无法接收到数据。文章提供了两种不同的前端实现方式,并展示了后台如何使用@RequestBody接收。同时,内容还涉及到了JavaScript的常用设计模式,如单体模式、工厂模式和例模式,以及函数相关的基础知识。作者分享了自己的IT行业经验,并提供了一份全面的Web前端开发学习资料,包括大厂面经、学习笔记和实战项目等。
摘要由CSDN通过智能技术生成

function(res) {

that.results.push({ title: “字符串”, result: res.data });

},

function(err) {

console.log(err);

}

);

},

  • BackEnd

@ResponseBody

@RequestMapping(value = “hex2decimal”, method = RequestMethod.POST)

public String hex2Decimal(String hex) {

return ConverterUtil.hex2Decimal(hex);

}

后台Spring端使用@requestBody接收

  • FrontEnd

hex2str1(hex) {

let that = this;

// method2: send parameter as usual, but use @RequestBody Map<String, String> to receive in Spring

let data = { hex: hex };

this.$http.post(“/test/tool/hex2string1”, data).then(

function(res) {

that.results.push({ title: “字符串”, result: res.data });

},

function(err) {

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值