Javascript angular向我的Web服务发送一个八位字节流,而不是json

Javascript angular向我的Web服务发送一个八位字节流,而不是json,javascript,jquery,spring,web-services,angularjs,Javascript,Jquery,Spring,Web Services,Angularjs,我有一个SpringWeb服务,它工作得很好,但它不会添加“factuur”。如果我使用restclient并发布帖子将“factuur”添加到我的数据库中,它将成功,但当我在angularjs中的客户端应用程序中执行此操作时,它将返回: org.springframework.web.HttpMediaTypeNotSupportedException:不支持内容类型“应用程序/八位字节流” spring Web服务中的我的控制器: @RequestMapping(value = "/",me

我有一个SpringWeb服务,它工作得很好,但它不会添加“factuur”。如果我使用restclient并发布帖子将“factuur”添加到我的数据库中,它将成功,但当我在angularjs中的客户端应用程序中执行此操作时,它将返回:

org.springframework.web.HttpMediaTypeNotSupportedException:不支持内容类型“应用程序/八位字节流”

spring Web服务中的我的控制器:

@RequestMapping(value = "/",method = RequestMethod.POST)
    public @ResponseBody void add(@RequestBody FacturatieView factuur){
        facturatieService.addFacturatie(factuur);
    }
在我的angular应用程序中,我有以下内容:

factory('factuurFactory', function($resource) {

            return $resource('http://localhost:8084/publictms/factuur/:id?CALLBACK=JSONP_CALLBACK', {}, {
                show: {method: 'GET', params: {id: '@id'}},
                delete: {method: 'DELETE', params: {id: '@id'}}
            });

        }).
        // In deze factory kan men alle voertuigen ophalen, wijzigen of een nieuwe toevoegen
        factory('facturenFactory', function($resource) {

            return $resource('http://localhost:8084/publictms/factuur/?CALLBACK=JSONP_CALLBACK', {}, {
                all: {method: 'GET', isArray: true},
                create: {method: 'POST', headers: {'Content-Type': 'application/json'}},
                update: {method: 'PUT', headers: {'Content-Type': 'application/json'}}
            });

        }).
        // CONTROLLER
        // Controller om de facturen te tonen en om een factuur te verwijderen
        controller('factuurCtrl', function($scope, $location, factuurFactory, facturenFactory) {

            // Haal de lijst van factuur op
            $scope.getList = function() {
                facturenFactory.all(function(data) {
                    $scope.facturen = data;
                });
            };

            // Navigeer naar een nieuw factuur aanmaken
            $scope.add = function() {
                $location.path('admin/facturen/nieuw');
            };

            // Navigeer naar de details van een factuur
            $scope.update = function(factuurId) {
                $location.path('admin/factuur/' + factuurId);
            };

            // Verwijder een factuur
            $scope.delete = function(factuurId) {
                factuurFactory.delete({id: factuurId}, function() {
                    $scope.getList();
                });
            };

            $scope.getList();

        }).
        // Controller om de details van een factuur te tonen en te wijzigen
        controller('factuurDetailCtrl', function($scope, $routeParams, factuurFactory, facturenFactory) {
            $scope.state = true;
            $scope.factuur = factuurFactory.show({id: $routeParams.id});
            $scope.edit = function() {
                $scope.state = false;
            };
            $scope.save = function() {
                facturenFactory.update($scope.factuur);
                $scope.state = true;
            };
            $scope.cancel = function() {
                $scope.state = true;
            };
        }).

注意:如果我在控制器中设置mediatype,我将不接受此八位字节流。有人知道为什么angular发送的是八位字节流而不是json吗?更新方法也可以很好地工作。

如果不使用标题会发生什么?不知道,但问题不是代码,而是在我的html中,数据绑定错误。不过还是谢谢你