415-不支持的媒体类型错误| angularjs+Spring3.2

415-不支持的媒体类型错误| angularjs+Spring3.2,angularjs,web-services,spring-mvc,http-post,http-status-code-415,Angularjs,Web Services,Spring Mvc,Http Post,Http Status Code 415,我在浏览器中遇到415个错误。我找不到这个错误。你能帮忙吗 loginController.js $scope.user={电子邮件:admin,密码:password} $http.post('/expense-manager-api/login/authenticate', $scope.user, { headers: {"Content-Type": "application/json"} }).success(function(login) { $scope.setEr

我在浏览器中遇到415个错误。我找不到这个错误。你能帮忙吗

loginController.js $scope.user={电子邮件:admin,密码:password}

$http.post('/expense-manager-api/login/authenticate', $scope.user, {
    headers: {"Content-Type": "application/json"}
}).success(function(login) {
    $scope.setError(login.status);
    $location.path("main");
}).error(function() {
    $scope.setError('Invalid user/password combination');
});
LoginController.java @控制器

@RequestMapping("/login")

public class LoginController {

@RequestMapping(value = "/authenticate", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public
@ResponseBody
LoginResponse login(@RequestBody LoginRequest loginRequest) {
    if (loginRequest.getEmail().equals("admin") && loginRequest.getPassword().equals("password")) {
        UUID uuid = UUID.randomUUID();

        return new LoginResponse(uuid.toString(), "OK");
    }

    return new LoginResponse(null, "Invalid user/password combination");
}
}


Jackson mapper解决了这个问题


在pom.xml中添加Jackson mapper的maven依赖项

你能在Firebug或Chrome开发控制台上发布HTTP请求吗?@Geo和我添加了照片。看起来Spring正在返回text/html。您确定日志中没有任何错误吗?是的。日志中没有错误。如果我调试服务器端代码。它甚至还没有到达方法的第一行。我的回应主体是LoginRespone,它是对象。它怎么可能是text/html?