GWT:在GET请求中捕获URL参数 [英] GWT: Capturing URL parameters in GET request
问题描述
我需要构建一个由具有特定URL参数的外部应用程序调用的GWT应用程序。
例如:
http://www.somehost.com/com.app.client.Order.html?orderId=99999 。
如何捕获GWT应用程序中的orderId参数?
试试,
String value = com.google.gwt.user.client.Window.Location.getParameter(orderId);
//将值解析为int
GWT可以调用原生javascript,这意味着如果JavaScript可以做到这一点,GWT也可以做到这一点;例如在GWT中,你可以写下:
pre $ public static native alert(String msg)
/ * - {
$ wnd.alert(Hey我是javascript);
} - * /;
在这种情况下,您甚至可以使用现有的javascript lib来提取查询字符串中的param值。 p>
I need to build a GWT application that will be called by an external application with specific URL parameters.
For example:
http://www.somehost.com/com.app.client.Order.html?orderId=99999.
How do I capture the orderId parameter inside the GWT application?
Try,
String value = com.google.gwt.user.client.Window.Location.getParameter("orderId");
// parse the value to int
P.S. GWT can invoke native javascript which means if javascript can do the stuff, GWT can do it too; e.g. in GWT, you can write
public static native void alert(String msg)
/*-{
$wnd.alert("Hey I am javascript");
}-*/;
In this case, you can even use existing javascript lib to extract param's value in the querystring.
这篇关于GWT:在GET请求中捕获URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!