使用Java在Google App Engine中读取请求参数 [英] Reading request parameters in Google App Engine with Java

查看:194
本文介绍了使用Java在Google App Engine中读取请求参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您使用Google Web Toolkit和Google App Engine创建新项目时,我正在修改Eclipse创建的默认项目。它是GreetingService示例项目。

I'm modifying the default project that Eclipse creates when you create a new project with Google Web Toolkit and Google App Engine. It is the GreetingService sample project.

如何在客户端的.java文件中读取请求参数?

How can I read a request parameter in the client's .java file?

例如,当前的URL是 http://127.0.0.1:8887/MyProj.html?gwt.codesvr=127.0.0.1&foo=bar ,我想使用像 request.getParameter(foo)==bar

For example, the current URL is http://127.0.0.1:8887/MyProj.html?gwt.codesvr=127.0.0.1&foo=bar and I want to use something like request.getParameter("foo") == "bar".

之类的东西,我看到文档中提到了Python的请求类,但我不能找不到Java的等价物。它被列在 google.appengine.ext.webapp 包中,但如果我尝试将它导入到我的.java文件(使用 com)。 前缀),它表示它无法解析 ext 部分。

I saw that the documentation mentions the Request class for Python, but I couldn't find the equivalent for Java. It's listed as being in the google.appengine.ext.webapp package, but if I try importing that into my .java file (with a com. prefix), it says that it can't resolve the ext part.

推荐答案

我可以使用 Window.Location via

<$ 4515148>这个答案

I was able to get it to work using Window.Location via this answer:

import com.google.gwt.user.client.Window;

// ...

Window.Location.getParameter("foo") // == "bar"

注意:

Note that:


位置是一个非常简单的包装,所以并非所有的浏览器怪癖都不会被用户隐藏。

Location is a very simple wrapper, so not all browser quirks are hidden from the user.

这篇关于使用Java在Google App Engine中读取请求参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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