我有这样简单的项目设置:
角控制器:
myApp.controller('signupCtrl', function ($rootScope, $scope, auth) {
"ngInject";
function successAuth(res) {
console.log(res);
}
$scope.addUser = function () {
$scope.userData = {
email: $scope.user.email,
password: $scope.user.password
};
console.log("form: ", $scope.userData);
angular.element('#register-modal').modal('hide');
auth.signup($scope.userData, successAuth, function (error) {
$rootScope.error = error;
console.log($rootScope.error);
});
};
});
角服务:
myApp.service('auth', function($http){
return {
signup: function(data,success, error){
$http.post('/registration/', data).success(success).error(error);
},
login: function(data,success, error){
$http.post('login', data).success(success).error(error);
}
};
});
弹簧控制器:
@RestController
public class UserController {
@RequestMapping(value = "/registration", method = RequestMethod.POST)
public void registration(User userBean) {
System.out.println("register");
System.out.println("name: " + userBean.getUsername());
}
}
的pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
当我从有角度的网页提交表格时,它根本没有击中弹簧控制器。我在控制台中找不到(404)。为什么会这样?