【问题标题】:How to start GWT from web service REST如何从 Web 服务 REST 启动 GWT
【发布时间】:2013-01-24 04:45:07
【问题描述】:

是否可以从 Web 服务 REST 运行 GWT 应用程序?

@Path("/main")
public class RestService {
  @GET
  @Path("{name}")
  public Response getUserByName(@PathParam("name") String name){

   // return Response.status(200).entity("My name is " + name).build();
  }
}

对我来说重要的是,调用 REST 的 URL 在 GWT 运行后不得更改。因此,当浏览器转到localhost:8080/application/main/adam 时,REST 运行并调用显示带有My name is adam 的消息框的GWT 应用程序。之后,我可以在浏览器中看到相同的 URL。

也许我应该解释我的要求的原因。 我想创建最终用户仅使用 URL 的应用程序,例如:

localhost:8080/application/somecommand/somedata

localhost:8080/application/anothercommand/anotherdata

没有窗口,没有表单,只有 URL。

【问题讨论】:

  • GWT 在大多数情况下在浏览器中运行。因此,您必须先将 URL 加载到浏览器中。只有这样 GWT 应用程序(从该 URL 加载)才会调用 Web 服务,在本例中为 RESTful。也许你需要解释你在想什么。如果我看不懂,可能其他人也有同样的问题。

标签: java web-services rest gwt


【解决方案1】:

是的,这是可能的。只需使用您的 GWT 应用程序提供 HTML 页面。

【讨论】:

    【解决方案2】:

    如果你可以像这样处理 URL:

    localhost:8080/application#somecommand/somedata 本地主机:8080/application#anothercommand/anotherdata

    这只是 GWT History-API

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-08
      • 1970-01-01
      • 2014-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-26
      相关资源
      最近更新 更多