Javascript @REST中的ModelAttribute为空

Javascript @REST中的ModelAttribute为空,javascript,angularjs,spring,forms,rest,Javascript,Angularjs,Spring,Forms,Rest,我试图通过将数据从HTML传递到我的RESTful。 该数据是字符串的数组。我不知道为什么当涉及到我的后端时,它是空的 这是我的休息: @PutMapping("/events") @Timed public ResponseEntity<Event> updateEvent(@RequestBody Event event, @ModelAttribute("attendeesToParse") ArrayList<String> attendeesToParse) t

我试图通过
将数据从
HTML
传递到我的
RESTful
。 该数据是字符串的数组。我不知道为什么当涉及到我的后端时,它是空的

这是我的
休息

@PutMapping("/events")
@Timed
public ResponseEntity<Event> updateEvent(@RequestBody Event event, @ModelAttribute("attendeesToParse") ArrayList<String> attendeesToParse) throws URISyntaxException {
    //Some code
}
我花了好几天的时间试图解决这个问题,我在谷歌上搜索了很多次,但都没有找到解决办法请帮帮我

由于项目的结构和业务逻辑,我无法将我的
HTML
更改为
JSP

为什么它是空的?如果我试图显示一些日志,我会看到一个空数组
[]

更新

我的
HTML表单调用

<form name="editForm" role="form" novalidate ng-submit="vm.save()">
    <!-- some code -->
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="vm.clear()">
             <span class="glyphicon glyphicon-ban-circle"></span>&nbsp;<span data-translate="entity.action.cancel">Cancel</span>
        </button>
        <button type="submit" ng-disabled="editForm.$invalid || vm.isSaving" class="btn btn-primary">
            <span class="glyphicon glyphicon-save"></span>&nbsp;<span data-translate="entity.action.save">Save</span>
        </button>
    </div>
</form>
我的
事件服务.js

(function() {
    'use strict';
    angular
        .module('businessRequestApp')
        .factory('Event', Event);

    Event.$inject = ['$resource', 'DateUtils'];

    function Event ($resource, DateUtils) {
        var resourceUrl =  'api/events/:id';

        return $resource(resourceUrl, {}, {
            'query': { method: 'GET', isArray: true},
            'get': {
                method: 'GET',
                transformResponse: function (data) {
                    if (data) {
                        data = angular.fromJson(data);
                        data.date = DateUtils.convertLocalDateFromServer(data.date);
                    }
                    return data;
                }
            },
            'update': {
                method: 'PUT',
                transformRequest: function (data) {
                    var copy = angular.copy(data);
                    copy.date = DateUtils.convertLocalDateToServer(copy.date);
                    return angular.toJson(copy);
                }
            },
            'save': {
                method: 'POST',
                transformRequest: function (data) {
                    var copy = angular.copy(data);
                    copy.date = DateUtils.convertLocalDateToServer(copy.date);
                    return angular.toJson(copy);
                }
            }
        });
    }
})();
(function () {
    'use strict';

    angular
            .module('businessRequestApp')
            .controller('EventController', EventController);

    EventController.$inject = ['Event', 'CustomUser', '$scope'];

    function EventController(Event, CustomUser, $scope) {

        var vm = this;

        vm.events = [];
        vm.customUsers = [];
        vm.usernames = ["test1", "test2", "test3"];

        $scope.allCustomUsers = [];

        loadAll();


        function loadAll() {
            Event.query(function (result) {
                vm.events = result;
                vm.searchQuery = null;
            });
            CustomUser.query(function (result) {
                vm.customUsers = result;
                vm.searchQuery = null;
                for (var i = 0; i < vm.customUsers.length; i++) {
                    $scope.allCustomUsers.push(vm.customUsers[i].username);
                }
            });
        }

    }
})();
My
event.controller.js

(function() {
    'use strict';
    angular
        .module('businessRequestApp')
        .factory('Event', Event);

    Event.$inject = ['$resource', 'DateUtils'];

    function Event ($resource, DateUtils) {
        var resourceUrl =  'api/events/:id';

        return $resource(resourceUrl, {}, {
            'query': { method: 'GET', isArray: true},
            'get': {
                method: 'GET',
                transformResponse: function (data) {
                    if (data) {
                        data = angular.fromJson(data);
                        data.date = DateUtils.convertLocalDateFromServer(data.date);
                    }
                    return data;
                }
            },
            'update': {
                method: 'PUT',
                transformRequest: function (data) {
                    var copy = angular.copy(data);
                    copy.date = DateUtils.convertLocalDateToServer(copy.date);
                    return angular.toJson(copy);
                }
            },
            'save': {
                method: 'POST',
                transformRequest: function (data) {
                    var copy = angular.copy(data);
                    copy.date = DateUtils.convertLocalDateToServer(copy.date);
                    return angular.toJson(copy);
                }
            }
        });
    }
})();
(function () {
    'use strict';

    angular
            .module('businessRequestApp')
            .controller('EventController', EventController);

    EventController.$inject = ['Event', 'CustomUser', '$scope'];

    function EventController(Event, CustomUser, $scope) {

        var vm = this;

        vm.events = [];
        vm.customUsers = [];
        vm.usernames = ["test1", "test2", "test3"];

        $scope.allCustomUsers = [];

        loadAll();


        function loadAll() {
            Event.query(function (result) {
                vm.events = result;
                vm.searchQuery = null;
            });
            CustomUser.query(function (result) {
                vm.customUsers = result;
                vm.searchQuery = null;
                for (var i = 0; i < vm.customUsers.length; i++) {
                    $scope.allCustomUsers.push(vm.customUsers[i].username);
                }
            });
        }

    }
})();
(函数(){
"严格使用",;
有棱角的
.module('businessRequestApp')
.控制器(“事件控制器”,事件控制器);
EventController.$inject=['Event','CustomUser','$scope'];
函数EventController(事件,CustomUser,$scope){
var vm=这个;
vm.events=[];
vm.customUsers=[];
vm.usernames=[“test1”、“test2”、“test3”];
$scope.allCustomUsers=[];
loadAll();
函数loadAll(){
事件查询(函数(结果){
vm.events=结果;
vm.searchQuery=null;
});
CustomUser.query(函数(结果){
vm.customUsers=结果;
vm.searchQuery=null;
对于(var i=0;i
如果您使用的是angularJS,则无法将数据绑定到@ModelAttribute,因为@ModelAttribute仅与JSP等模板引擎一起存在,而angularJS不是Spring中的模板引擎。尝试在字符串参数上使用@RequestBody,然后使用Jackson提取数据


还有一个问题,你到底是如何将你的价值观从前面传递到后面的?我没有看到任何
$http
angularJS调用,也没有使用POST方法的HTML表单。

谢谢你的回答,但我得到了这个答案:
org.springframework.http.converter.httpMessageNodeEnableException:读取输入消息时发生I/O错误;嵌套异常是java.io.IOException:UT010029:流已关闭
我尝试了
String[]
而不是
ArrayList
,但例外情况是一样的。我读到只有1个
@RequestBody
可能。我做了一个测试,将所有请求内容包装到1个
字符串
,但我用
给出的属性仍然是空的。我使用
@RequestParam
进行了测试,但它表明参数
attendestoparse
为空。如何修复此问题?我更新了所有信息,添加了所有
.js
文件和调用
HTML
form@mosherad的代码。请注意,这是一个
PUT
,而不是
POST
调用。您可以通过POST和PUT发送http正文