Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何将pojo数据添加到$scope模型以在网页上显示数据?_Java_Angularjs_Pojo - Fatal编程技术网

Java 如何将pojo数据添加到$scope模型以在网页上显示数据?

Java 如何将pojo数据添加到$scope模型以在网页上显示数据?,java,angularjs,pojo,Java,Angularjs,Pojo,我有一个bean类对象,我想将这个bean发送到angularjs$scope的模型,以便显示数据。我尝试使用Json对象,但无法理解正确的语法 这是控制器。StudentsBean是包含数据的bean类 PrintWriter pw=response.getWriter(); StudentsService studentsService=new StudentsService(); List<StudentsBean> studentsBean=stude

我有一个bean类对象,我想将这个bean发送到angularjs$scope的模型,以便显示数据。我尝试使用Json对象,但无法理解正确的语法

这是控制器。StudentsBean是包含数据的bean类

    PrintWriter pw=response.getWriter();
    StudentsService studentsService=new StudentsService();
    List<StudentsBean> studentsBean=studentsService.getStudentsDetails();
    JsonObject jsonObject = new JsonObject();
    Gson gson=new Gson();
    String json=gson.toJson(studentsBean);
    gson.toJson(studentsBean, pw);

我无法理解如何连接Java类(控制器)和Angularjs代码。

//Java控制器返回学生列表

@GetMapping(“/AngularJSPrac/students”) 公共列表getStudentsDetails(){

//安格拉斯

$scope.getstudentList = function () {
    $http.get("/AngularJSPrac/students")
        .success(function (data) {
            console.log("listdata"+JSON.stringify(data));

        })

};

试试看这篇文章,它会对你有所帮助。
     StudentsService studentsService=new StudentsService();

     return studentsService.getStudentsDetails();   
}
$scope.getstudentList = function () {
    $http.get("/AngularJSPrac/students")
        .success(function (data) {
            console.log("listdata"+JSON.stringify(data));

        })

};