2017-11-22 2 views
0

각도 js 페이지에서이 값을 가져 와서 JSP 페이지에 세부 사항을 표시하는 방법.이 값을 얻고 각도 JS에서 Ajax 호출을 사용하여 볼 수있는 몇 가지 도움말을 제공하십시오.각도 JS를 사용하여 컨트롤러에서 JSP로 데이터를 가져 오는 방법

@RequestMapping(value = "/search", method = RequestMethod.GET) 
    public 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()); 
     } 

내 각도 JS 페이지 : 이것은 내 JSP 페이지가 난 내 JSP로 page.i 내 데이터의 취득 내가 컨트롤러에서 아약스 전화를 사용하여 내 데이터를 가져 오는 방법을 dono 얻기 위해 많은 시도하는 방법 dono

입니다 내 데이터는 응답 형식입니다.

<!doctype html> 
<html ng-app> 
    <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(data) { 
        $scope.employees = data; 
       }); 
     } 
     </script> 
    </head> 
    <body> 
     <div ng-controller="Hello"> 
     <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-app="your appName" ng-controller="Hello"> 
<tr ng-repeat="employee in employees"> 
<td>{{employee.id}}</td> 
    <td>{{employee.name}}</td> 
    <td>{{employee.age}}</td> 
    <td>{{employee.salary}}</td> 
    <td>{{employee.address}}</td> 
    <td>{{employee.bloodgrp}}</td> 
    <td>{{employee.aids}}</td> 
    <td>{{employee.weight}}</td> 
    </tr> </tbody> 
      </table> 
     </div> 
    </body> 
</html> 
+0

안녕하세요. StackOverflow에 오신 것을 환영합니다. 도움말 페이지, 특히 [여기에 관해서 내가 무엇에 관해 물을 수있는 주제는 무엇입니까?] (http://stackoverflow.com/help/on-topic) 섹션과 [ "어떤 유형의 질문을해야합니까? 묻지 마시오? "] (http://stackoverflow.com/help/dont-ask). 더 중요한 것은 [Stack Overflow question checklist] (http://meta.stackexchange.com/q/156810/204922)를 읽어보십시오. [Minimal, Complete, Verifiable Examples] (http://stackoverflow.com/help/mcve)에 대해 배우고 싶을 수도 있습니다. – Clijsters

+0

당신의 angularJS 코드는 어디에 있습니까? angularJS에서 json 응답을 사용하는 방법을 알고 있습니까? –

+0

각도 js에서 json 응답을 사용하는 방법이 없습니다 – Ajay

답변

관련 문제