在 GWT 中使用查询字符串 [英] working with Query String in GWT

查看:35
本文介绍了在 GWT 中使用查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须创建一个包含用户 ID 和电子邮件参数的动态 URL,它将直接用于我的 GWT 应用程序中的注册表单.我想设置和获取查询字符串中的参数.我已经提到了 tp http://code.google.com/p/gwt-examples/source/browse/trunk/System/src/com/gawkat/gwt/system/client/global/QueryString.java?r=1241 但是这里我的项目无法访问 QueryStringData.请告诉我该怎么做?任何替代方案也可以帮助我.

I have to created a dynamic URLcontaining the user id and email parameters, which will direct to sign up form in my GWT application. I want to set and get the parameters in the query string. I have referred tp http://code.google.com/p/gwt-examples/source/browse/trunk/System/src/com/gawkat/gwt/system/client/global/QueryString.java?r=1241 but here QueryStringData is inaccessible to my project.Please tell me how I can do it? Any alternative could also help me.

推荐答案

不要认为 GWT 中有一个简单的标记化查询字符串解析器.但是您可以使用以下方法获取原始查询字符串:

Don't think there's a simple tokenized query string parser in GWT. But you can get the raw query string by using:

String queryString = Window.Location.getQueryString();

以您喜欢的任何方式解析它.我用它来设置调试标志等:

Parse it any way you like. I use it like this to set debug flags etc.:

boolean debugMode = Window.Location.getQueryString().indexOf("debug=true") >= 0;

请注意,更改 url 查询部分中的值(在 ?# 之间)将重新加载页面.更改 url 的哈希部分"(# 之后的任何内容)不会重新加载页面.这就是 com.google.gwt.user.client.History 使用哈希部分的原因.

Note that changing values in the query part of the url (between the ? and the #) will reload the page. While changing the "hash part" of the url (anything after the #) will not reload the page. Which is why the com.google.gwt.user.client.History uses the hash part.

这篇关于在 GWT 中使用查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆