gpt4 book ai didi

rest - Play 框架中 XML/Json 中的错误消息

转载 作者:行者123 更新时间:2023-12-04 06:17:56 24 4
gpt4 key购买 nike

我正在尝试为 Play 开发 REST API。我有两个问题:

  • 为什么 badRequest 不能添加消息?
  • 虽然我设置了 render.format = "json",但错误信息是用纯文本写的。
    是否可以将其包装成render.format的格式?
  • 最佳答案

    也许你可以使用这个方法

    void error(int status, String reason) 

    向客户端发回带有 http 状态代码的消息和文本消息。

    关于rest - Play 框架中 XML/Json 中的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6996517/

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