gpt4 book ai didi

model-view-controller - 将 XML 集成到现有 View 中

转载 作者:行者123 更新时间:2023-12-02 15:36:02 24 4
gpt4 key购买 nike

我正在将 Grails 应用程序转换为使用 REST 架构,并希望使用现有 View 。

我遇到的所有 REST 教程都涉及 URL 重定向和 Controller 操作。问题是,没有人关心显示数据,这就是重点!

当我访问信息时,它会显示格式正确的 XML。如何将其与现有 View 一起使用?

最佳答案

好吧,因为它是同一件事。

即 localhost/bookstore/book/1 将调用 book Controller 的 show

  • 如果您从浏览器调用它,它将呈现 html View 。
  • 如果您使用 curl 或 postman (chrome) 调用并添加:
    接受:文本/xml
    内容类型:文本/xml
    它将返回 XML

  • 现在,如果您想从 View 中调用休息 Action ,那是一个 ajax 问题。所以检查 jquery ajax 文档...

    关于model-view-controller - 将 XML 集成到现有 View 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10485678/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com