java - 如何通过客户端 Java 代码获取 Google Web Toolkit 中的当前 URL?

标签 java url gwt httpwebrequest

我正在尝试 read the query arguments of the URL在客户端 Java 代码中,但我不知道如何在 Java 中找到当前 URL。

当我按照 this question 中的建议尝试使用 httpServletRequest 时,它说它无法解决并且不提供添加导入语句。

我将 Google Web Toolkit 与 Google App Engine 结合使用。

最佳答案

Window.Location :

public static class Window.Location

This class provides access to the browser's location's object. The location object contains information about the current URL and methods to manipulate it. Location is a very simple wrapper, so not all browser quirks are hidden from the user.

有许多方法可以检索有关 URL 的信息,包括获取整个信息 (getHref()) 或获取组成部分(例如 getProtocol()getHost()getHostName() 等)的方法。

既然你说你想读取查询参数,你可能想要以下之一:

static java.lang.String getQueryString()
   Gets the URL's query string.

static java.lang.String getParameter(java.lang.String name)
  Gets the URL's parameter of the specified name

static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getParameterMap() 
  Returns a Map of the URL query parameters for the host page; since changing the map would not change the window's location, the map returned is immutable.

关于java - 如何通过客户端 Java 代码获取 Google Web Toolkit 中的当前 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4515052/

相关文章:

java - 当我从 addMouseListener 关闭我的框架时,它说这是不兼容的类型,那么我可以用什么来改变它呢?

javascript - 如何根据页面url获取元素

url - 从 MQL4 执行 URL

iPhone SDK : NSURL string errors/% sign confrontation

java - GWT CellList 渲染完成处理程序?

java - 在Java中,我的MouseMotionListener和MouseListener正在检测点击,但不检测移动

java从json中读取日期

java - Activity 不显示 onClick

java - 如何创建自定义 GWT CellTable 类?

java - 像 google inbox 一样将 java 翻译成 javascript