我使用vue2写了一个登录页面,然后使用request.post将表单数据传到后端使用@Restbody接收封装在实体类中,为什么我的实体类收不到数据。
这是前端登录函数
login(){
request.post("/user",this.user).then(res => {
if(!res){
console.log(res)
console.log(this.user)
this.$message.error("登录失败")
}else{
console.log(this.user)
this.$router.push("/Home")
}
})
}
这是cusercontroller的接收
@Resource
private cusermapper cusermapper;
@PostMapping
public boolean login(@RequestBody cuserDTO cuserDTO)
{System.out.println(cuserDTO.getCname());
String username=cuserDTO.getCname();
String password=cuserDTO.getCpassword();
if(StrUtil.isBlank(username)||StrUtil.isBlank(password))
{ System.out.println(username);
return false;
}else {
List<cuser> data= cusermapper.login(cuserDTO);
if (data==null){return false;}
else {return true; }
}}
封装类
package com.example.demo.controller.dto;
import lombok.Data;
@Data
public class cuserDTO {
private String Cname;
private String Cpassword;
}