0
위의 클래스가 있는데이 메서드는 xml 결과를 반환합니다.AngularJS rest XML 데이터 얻기
@RestController
@RequestMapping("api/")
public class RateController {
@RequestMapping(value = "/currencies/{ids}")
public Currency getRates(@PathVariable String ids) throws JAXBException, IOException {
JAXBContext jc = JAXBContext.newInstance(Currency.class);
//...
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(currency, System.out);
return currency;
}
}
나는 angularjs에서 가져 오려고하지만 데이터를 가져갈 수 없습니다. angularJS에서 xml formate의 데이터를 어떻게 얻을 수 있습니까? 그 방법은 위와 같습니다.
var CurrencyController = function($http, $scope, $routeParams, exampleSvc) {
var getCurrencies = function(data) {
var result = $http.get("/api/currencies/" + $scope.ids);
var x2js = new X2JS();
var json = x2js.xml_str2json(result);
onCurrencyComplete(json);
};
var onCurrencyComplete = function(response) {
$scope.currencies = response.data;
};
내가했지만 이전과 여전히 동일합니다. – Alex
어떤 오류가 발생합니까 ?? – Rahul