将 URL 从 AppEngine 发送到 Java 应用程序

发布于 2024-12-23 04:57:34 字数 268 浏览 1 评论 0原文

我正在使用带有 Google AppEngine 的 Java 应用程序。我向 servlet 发送 post 请求,它需要使用一些未知数量的 URL 进行响应。

我想知道实现这一点的最佳方法是什么。在应用程序中创建 URL 对象并将其作为 JSON 发送,或者然后在 Java 应用程序中重新转换它,或者只是将 URL 作为带有某些分隔符的字符串发送?

有没有办法像我们处理请求对象一样在响应对象中发送参数,或者设置 MIME 类型,以便我们可以在 Java 应用程序中轻松获取 URL?

I'm using a Java application with Google AppEngine. I send post requests to the servlet and it needs to response with some unknown number of URL's.

I was wondering what would be the best way to implement this. Making URL object in the app and sending it as JSON or then reconverting it in the Java application or just sending the URLs as String with some delimiter ?

Is there a way to send parameters in response objects like we do with request objects or maybe set the MIME type so we can get the URLs easily in the Java application ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

把梦留给海 2024-12-30 04:57:34

我建议只返回一个 JSON 数组; Java 中有一些很好的库(请参阅 Jackson Vs. Gson)来从 Java 对象创建 JSON 并解析 JSON在 javascript 中显然是一个已解决的问题。依靠众所周知的代码来完成所有编码/解码是一个巨大的帮助。

I'd recommend just returning a JSON array; there are good libraries in Java (see Jackson Vs. Gson) to create JSON from Java objects and parsing JSON in javascript is obviously a solved problem. Relying on well-known code to do all the encoding/decoding is a huge help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文