angularjs rest以json格式返回xml [duplicate](angularjs rest call return xml in json format [duplicate])
这个问题在这里已有答案:
我在我的应用程序中使用angularjs和spring mvc。 angularjs使用休息来调用弹簧控制器。 控制器调用返回XML的外部URL。
现在,我想以json格式将此XML发送到angularjs。 我可以将xml转换为java对象(使用jaxb)并使用jackson-databind jar将java转换为json。 但是,从外部URL返回的xml结构是动态的,并且可以在不受我控制的任何时间进行更改。 在这种情况下,如果xml结构发生更改,我将不得不修改我的java对象。 这很乏味。
相反,如果我可以以json的形式将xml响应直接发送到angularjs,它将使我的任务更容易。
有没有办法实现这个目标?
或者,我可以直接在angularjs中调用外部URL吗? 返回的xml会自动转换为json吗? 或者我应该使用任何组件或JS库将其转换为json?
This question already has an answer here:
- How to handle XML services in AngularJS? 5 answers
I am using angularjs and spring mvc in my application. angularjs invokes spring controller using rest. The controller invokes external URL that returns XML.
Now, I want to send this XML to angularjs in json format. I can convert the xml into java objects (using jaxb) and use jackson-databind jar to convert java into json. However, the xml structure returned from the external URL is dynamic and can change any time that is not under my control. In this scenario, if the xml structure changes, I will have to modify my java object. This is tedious.
Rather, if I can send the xml response directly to angularjs in the form of json, it will make my task easier.
Is there any way to achieve this?
Alternatively, can I invoke the external URL directly in angularjs? Will the returned xml be converted to json automatically? Or should I be using any component or JS library to convert it into json?
原文:https://stackoverflow.com/questions/42639745
最满意答案
问题无关紧要。 出现此问题的原因是config.xml以某种方式损坏了。
Question is not relevant. the reason for this problem is that the config.xml was somehow corrupted.
相关问答
更多-
“views”目录缺失(“views” directory missing)[2021-12-18]
预计会有一个应用程序范围的布局文件(命名为缺少的)。 创建或复制该文件,事情应该再次起作用。 It's expected there will be an app-wide layout file (named as what's missing). Create or copy that file and things should be working again. -
问题无关紧要。 出现此问题的原因是config.xml以某种方式损坏了。 Question is not relevant. the reason for this problem is that the config.xml was somehow corrupted.
-
我建议使用Build User Vars Plugin以透明地提供稍后要使用的用户特定变量。 这个插件提供了几个变量: 模板项目插件可用于定义具有关于实际构建过程的所有必需配置的作业。 有了这个,您可以创建几个“包装”作业,遵循%UserName-JobName%模式,因此拥有不同视图,配置为仅为特定用户显示作业将是一件非常容易的任务。 假设包装器作业只执行上层模板作业(使用上层构建器)。 另请考虑Hudson Personal View插件 。 I would suggest to use Build U ...
-
Swift嵌套堆栈视图(Swift Nested Stack Views)[2021-04-23]
你真的只错过了两个设置: loginView.snp.makeConstraints{(make) -> Void in make.height.equalTo(superview!); make.width.equalTo(superview!); // you also need to set position, // this will center the view make.centerX.equalTo(s ... -
您的要求是多个命名视图。 以下文档对于在单个页面中实现多个视图很有用https://github.com/angular-ui/ui-router/wiki/Multiple-Named-Views 有关这方面的更多信息,请点击此处 Your requirement is multiple named views. Following document is useful to implement multiple views in a single page https://github.com/angu ...
-
所以我找到了一个可行的答案来解决手头的问题,经过广泛的研究和询问后,我选择了1个控制器和配置状态 $stateProvider.state("main", { url: "/", controller: "mainController", templateUrl: "temps/primary.html" }); $urlRouterProvider.otherwise("/"); 进入配置设置,然后我的控制器看起来像这样: app.controller("mainControll ...
-
嵌套的Monotouch对话框RootElement视图中缺少后退按钮(Back Button missing from nested Monotouch Dialog RootElement Views)[2023-07-14]
这是因为我们使用DialogViewController的View的方式。 获取UINavigationController以推动ViewController查看其ParentViewController的代码( 如您所见 )。 但是正如问题所述,我们将DialogViewController的View提升到我们的ViewController中,这是异常使用。 以下是Monotouch Dialog(MT D)中的代码。 检查nav的代码不是null总是发现它是null,因为在我们的用例中UINavigat ... -
Ionic中的多个嵌套视图(Multiple nested views in Ionic)[2023-03-24]
您可以将其中一个作为指令,您可以看到此链接以了解如何使用指令https://docs.angularjs.org/guide/directive you can make one of them as a directive you can see this link to figure out how to use directive https://docs.angularjs.org/guide/directive -
是的,您可以嵌套部分视图。 只要确保传递正确的模型。 HtmlHelpers在这里非常有用,因为您可以使用完整视图路径封装对RenderPartial的调用,并确保使用正确的模型。 例 public static void RenderSomePartial(this HtmlHelper helper, int? i) { helper.RenderPartial("~/Views/Shared/SomePartial.cshtml", i); } Yes, you can nest parti ...
-
如果您要在不同时间替换子视图,或者如果子视图的类型非常不同,则布局对此有好处...例如,布局可能包含您的标题,导航和主要内容区域。 其他选项包括CollectionViews和CompositeViews。 集合视图将呈现项目集合,对集合中的每个项目使用相同类型的视图。 这适用于事物列表。 CompositeViews是CollectionViews,可以围绕集合呈现包装器模板。 例如,HTML表结构。 table , thead , tbody和tfooter标签可以在CompositeView的包装器模 ...