i want to post json data to spring mvc controller by Angularjs. For this purpose i wrote this code. but when i post form bad request error display in console.for simple data it work correctly but for nested object not work. how i post nested json object to controller?
my entity :
public class TestData {
private String name;
private List<TestData2> data;
}
public class TestData2 {
private String email;
private String body;
}
and in jsp page:
<form ng-submit="add(ab)">
<input type="text" ng-model="ab.name">
<input type="text" ng-model="ab.data[0].email">
<input type="text" ng-model="ab.dat[0].body">
</form>
and in Angularjs controller:
app.controller('myController', function ($scope, $http) {
$scope.ab = {};
$scope.addComment = function(ab) {
console.log(ab);
$http.post('/add', ab).success(function(response){}
)};
Aucun commentaire:
Enregistrer un commentaire