问题描述
后台只能接收get请求,使用post传值接收的数据为null
问题出现的环境背景及自己尝试过哪些方法
打断点看了一下post请求传过来的值为null
使用postman测试的,本以为是测试软件的问题,之后自己写了一个form表单测试,结果相同,
使用post传值不能接收到数据
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
@RequestMapping(value = "login.do", method = RequestMethod.GET)
@ResponseBody
public ServerResponse<User> login(String username,String password, HttpSession session){
ServerResponse<User> response = iUserService.login(username,password);
if(response.isSuccess()){
session.setAttribute(Const.CURRENT_USER,response.getData());
}
return response;
}
你期待的结果是什么?实际看到的错误信息又是什么?
username 和 password 应该可以接收到前端传过来的值
但是实际上并没有接收到,值为null
@RequestMapping(value = "login.do", method = RequestMethod.GET) 你这边写要求的是get请求啊