【发布时间】:2025-12-24 01:50:11
【问题描述】:
我正在尝试 Spring 框架。 我有 RestController 和函数:
@RequestMapping(value="/changePass", method=RequestMethod.POST)
public Message changePassword(@RequestBody String id, @RequestBody String oldPass,
@RequestBody String newPass){
int index = Integer.parseInt(id);
System.out.println(id+" "+oldPass+" "+newPass);
return userService.changePassword(index, oldPass, newPass);
}
和代码 angularJS
$scope.changePass = function(){//changePass
$scope.data = {
id: $scope.userId,
oldPass:$scope.currentPassword,
newPass:$scope.newPassword
}
$http.post("http://localhost:8080/user/changePass/", $scope.data).
success(function(data, status, headers, config){
if(date.state){
$scope.msg="Change password seccussful!";
} else {
$scope.msg=date.msg;
}
})
.error(function(data, status, headers, config){
$scope.msg="TOO FAIL";
});
}
当我运行它时。
错误信息:
Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public com.csc.mfs.messages.Message com.csc.mfs.controller.UserController.changePassword(java.lang.String,java.lang.String,java.lang.String)
请帮我修一下……
【问题讨论】:
标签: java angularjs spring-mvc