Javascript AngularJs控制器获取请求未命中Spring MVC Rest服务

Javascript AngularJs控制器获取请求未命中Spring MVC Rest服务,javascript,angularjs,spring,rest,Javascript,Angularjs,Spring,Rest,因此,我有我的角度javascript作为 var app = angular.module('app', []); app.controller('controller', function($scope, $http) { $http.get('http://localhost:8080/core/students.json') .success(function(data) { $sco

因此,我有我的角度javascript作为

    var app = angular.module('app', []);
    app.controller('controller', function($scope, $http) {
        $http.get('http://localhost:8080/core/students.json')
                .success(function(data) {
                    $scope.user = data;
                });
    });
还有我的休息控制器

@RestController
public class StudentRestController {

@RequestMapping(value = "/students", produces = { "application/json" }, method =      RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public Student getStudent() {
    // return studentService.getStudentByUserName(userName);
    Student s = new Student();
    s.setUserName("userName");
    s.setEmailAddress("email");
    return s;
}
}
但是由于某些原因,javascript ajax请求没有命中getStudent()方法。为什么会这样?我得到一个控制台错误

"GET http://localhost:8080/core/students.json 404 (Not Found)"

普通按钮url调用按预期工作

您正在@RequestMapping上定义“/students”,那么您的url应该是“../core/students”。

将angularjs应用程序更改为

var app = angular.module('app', []);
app.controller('controller', [ "$scope", "$http", function($scope, $http) {
    $http.get("http://localhost:8080/students").success(function(data) {
        $scope.user = data;
    });
} ]);
如果ur
web.xml

<servlet-mapping>
        <servlet-name> dispatcherServlet </servlet-name>
        <url-pattern> * </url-pattern>
    </servlet-mapping>

调度员服务
*