How to get this value in angular js page to display the details in JSP page.please some one help to get this value and view it in Angular JS using Ajax call.
@Controller
public class EmployeeController {
@Autowired
private EmployeeService employeeService;
@RequestMapping(value = "/iwill", method = RequestMethod.GET)
public ModelAndView searchd() {
return new ModelAndView("search");
}
@RequestMapping(value = "/search", method = RequestMethod.GET)
public @ResponseBody void search(HttpServletResponse res,HttpServletRequest req) throws IOException {
List<Employee> data = employeeService.listEmployeess();
JSONArray array = new JSONArray();
for (Employee e : data) {
JSONObject jsonObject = new JSONObject(e);
array.put(jsonObject);
}
res.getWriter().append(array.toString());
}
}
my Angular js page:
Here i do no how to get my data.if i simply (http://localhost:8080/sdnext/search.html )use this url its showing json data if i implement in angular js its not throwing error but no data's get displayed.
<!doctype html>
<html >
<head>
<title>Spring MVC + AngularJS Demo</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script>
function Hello($scope, $http) {
$http.get('http://localhost:8080/sdnext/search.html').
success(function(response) {
$scope.employees = response.data;
});
}
</script>
</head>
<body ng-app="app">
<table>
<tr>
<th>Id</th>
<th>Name</th>
<th>Age</th>
<th>salary</th>
<th>Address</th>
<th>BloodGrp</th>
<th>Aids</th>
<th>Weight</th>
</tr>
<tr>
<tbody ng-controller="Hello">
<tr ng-repeat="employee in employees">
<td>{{employee.empId}}</td>
<td>{{employee.empName}}</td>
<td>{{employee.empAge}}</td>
<td>{{employee.salary}}</td>
<td>{{employee.empAddress}}</td>
<td>{{employee.bloodgrp}}</td>
<td>{{employee.aids}}</td>
<td>{{employee.weight}}</td>
</tr> </tbody>
</table>
</body>
</html>
**
My JSON response i given below: This im getting while using the url http://localhost:8080/sdnext/search.html but i dono how to use this in Angular js to display my data in jsp page.
**
[{"empId":1,"bloodgrp":"0-ve","empName":"krishnaKumars","weight":78,"aids":"negative","empAge":23,"salary":15000,"empAddress":"madurai"},{"empId":2,"bloodgrp":"o-ve","empName":"Archanasundar","weight":68,"aids":"Negative","empAge":31,"salary":50000,"empAddress":"chennai"},{"empId":4,"bloodgrp":"o-ve","empName":"Kabali","weight":78,"aids":"negative","empAge":23,"salary":201300,"empAddress":"Madurai"}]