axios发送post请求报错400问题
最近在做一个springboot+vue前后端分离项目,编写前端页面请求数据用的axios,请求代码如下
methods: {
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
//向后台发送post请求
this.$axios.post('http://localhost:8080/login',this.ruleForm).then(res=>{
console.log(res.headers)
console.log(res)
})
} else {
console.log('error submit!!');
return false;
}
});
}
反复核对前端代码后确定编写方式和路由路径都无误,所以去看了后端代码,发现后端报错了
于是根据错误提示去查看JwtUtils类的代码,发现是配置文件前缀写错了,现已改正
JwtUtils.java
application.yml
上面两个文件中框出来的部分应该是一致的,因为@ConfigurationProperties这个注解后面括号里的就是指明在配置文件里的位置