如何将表单参数传递给弹簧控制器。我需要将下面的表格提交到这个 url “submit.htm”。
<form data-bind="submit: save" action="forms/submit.htm" method="post">
<fieldset>
<legend>User: <span data-bind='text: errors().length'></span> errors</legend>
<label>First name: <input data-bind='value: firstName'/></label>
<label>Last name: <input data-bind='value: lastName'/></label>
</fieldset>
<button type="submit">Go</button>
</form>
JS:
var viewModel = {
firstName: ko.observable().extend({
required: true,
minLength: 2,
maxLength: 10
}),
lastName: ko.observable().extend({
required: true
}),
tasks: ko.observableArray([]),
save: function() {
if (viewModel.errors().length == 0) {
ko.utils.postJson($("form")[0], this);
} else {
alert('Please check your submission.');
viewModel.errors.showAllMessages();
}
}
};
viewModel.errors = ko.validation.group(viewModel);
ko.applyBindings(viewModel);
这将交给我的控制器。但我没有在我的控制器中获得这些参数。我也不知道如何在我的控制器中获取这些参数。