get请求
get的简写:
axios.get("http://localhost/ajaxServlet",{params:{username:"1"}}).then(res=>{
console.log(res)
})
get请求
因为axios使用post携带参数默认使用application/josn所以后台 可能接受不到参数
解决:
1.不使用data使用params传递
2.使用data传递,在接受端的参数上加上@requestBody注解让其转化成java对象
post简写
//使用params
axios.post("http://localhost/ajaxServlet","username:1&age=10").then(res=>{
console.log(res)
}).catch(err=>{
console.log(err)
})
//使用data
axios.post("http://localhost/ajaxServlet",{username:'zhangsan'}).then(res=>{
console.log(res)
}).catch(err=>{
console.log(err)
})



