Java 如何将pojo数据添加到$scope模型以在网页上显示数据?
我有一个bean类对象,我想将这个bean发送到angularjs$scope的模型,以便显示数据。我尝试使用Json对象,但无法理解正确的语法 这是控制器。StudentsBean是包含数据的bean类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
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));
})
};