基于vue+spring boot的前端发送get请求,后端如何接收的问题
一、前端
第一种写法
functionName(){
this.$axios.get("url",{
params: {
key:value
key2:value2
}}).then(res=>{
console.log(res.data)
}).catch(err=>{
console.log(err)
}),
第二种写法
functionName(){
this.$axios
.get("url?value="+this.vlaue+"&value2="+value2)
.then(res=>{
console.log(res.data)
}).catch(err=>{
console.log(err)
})
}
二、后端
@ResponseBody
@GetMapping("/url")
public Object functionName(
@RequestParam("key") object value,
@RequestParam("key2") object value2){
//函数操作
return null;
}
这样就可以前后端进行交互了