首页 \ 问答 \ angularjs rest以json格式返回xml [duplicate](angularjs rest call return xml in json format [duplicate])

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:

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
更新时间:2022-06-26 15:06

最满意答案

问题无关紧要。 出现此问题的原因是config.xml以某种方式损坏了。


Question is not relevant. the reason for this problem is that the config.xml was somehow corrupted.

相关问答

更多
  • 预计会有一个应用程序范围的布局文件(命名为缺少的)。 创建或复制该文件,事情应该再次起作用。 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 ...
  • 你真的只错过了两个设置: 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 ...
  • 这是因为我们使用DialogViewController的View的方式。 获取UINavigationController以推动ViewController查看其ParentViewController的代码( 如您所见 )。 但是正如问题所述,我们将DialogViewController的View提升到我们的ViewController中,这是异常使用。 以下是Monotouch Dialog(MT D)中的代码。 检查nav的代码不是null总是发现它是null,因为在我们的用例中UINavigat ...
  • 您可以将其中一个作为指令,您可以看到此链接以了解如何使用指令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的包装器模 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)