我在angularJS中有一个post方法,我将post方法发送到Spring MVC,但是Spring MVC没有返回新的ModelAndView。
AngularJS **
var app = angular.module('userApp', []);
app.controller('userController', [ "$scope", "$http",
function($scope, $http) {
$scope.user = {};
$scope.addUser = function() {
var response = $http.post('resultA', $scope.user)
response.success(function(data, status, headers, config) {
$scope.message = data;
});
response.error(function(data, status, headers, config) {
alert("failure message: ");
});
alert("aa");
$scope.name = '';
$scope.employees = '';
$scope.headoffice = '';
};
} ]);
SPRING MVC
@RequestMapping(value = "/resultA", method = RequestMethod.POST)
public @ResponseBody ModelAndView submitFormA(@RequestBody User user) {
System.out.println(user.getUsername()+"");
return new ModelAndView("resultA");
}
答案 0 :(得分:0)
您的代码看起来很好。请确保存在resultA
视图。或者,如果要返回String,请将方法返回类型更改为String
。