gwt中的HTTPRequest导入错误

gwt中的HTTPRequest导入错误,gwt,Gwt,我正在学习GWT并尝试创建一个示例应用程序。GWT版本是2.5.1。在EntryPint中,我有这个代码 HTTPRequest.asyncGet (GWT.getHostPageBaseURL() + "person.xml", new ResponseTextHandler() { public void onCompletion(String responseText) { // code goes here }

我正在学习GWT并尝试创建一个示例应用程序。GWT版本是2.5.1。在
EntryPint
中,我有这个代码

HTTPRequest.asyncGet
  (GWT.getHostPageBaseURL() + "person.xml",
       new ResponseTextHandler() {
         public void onCompletion(String responseText) {
           // code goes here
         }
       }
我确实有
HTTP
的导入

import com.google.gwt.user.client.HTTPRequest;
但这无法导入,错误如下所示-

[javac] import com.google.gwt.user.client.HTTPRequest;
[javac]                                  ^
[javac] symbol  : variable HTTPRequest
[javac] location: class com.google.gwt.sample.client.TalkToServer
[javac]     HTTPRequest.asyncGet
另外,我在gwt.xml文件中添加了这一行

<inherits name='com.google.gwt.http.HTTP'/> 


我在这里遗漏了什么吗?

要从服务器获取XML,请尝试以下操作:

    final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, “person.xml“);
    builder.setCallback(new RequestCallback() {
        @override
        public void onError(final Request request, final throwable exception) {
            // handle Exception
        }
        @override
        public void onResponseRecieved(final Request request, final Response response) {
            // handle Reponse  - use response.getText() to get the response text
        }
    };
使用GWT XML处理来解析XML。您可以在此处找到信息:


希望这有助于从服务器获取XML,请尝试以下操作:

    final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, “person.xml“);
    builder.setCallback(new RequestCallback() {
        @override
        public void onError(final Request request, final throwable exception) {
            // handle Exception
        }
        @override
        public void onResponseRecieved(final Request request, final Response response) {
            // handle Reponse  - use response.getText() to get the response text
        }
    };
使用GWT XML处理来解析XML。您可以在此处找到信息:


希望这有助于

com.google.gwt.user.client.HTTPRequest
从GWT1.5(5年多前)开始就被弃用,并在GWT2.1.0(3年前)中被删除


请改用
com.google.gwt.http.client.RequestBuilder

com.google.gwt.user.client.HTTPRequest
自GWT1.5(5年多前)起就被弃用,并在GWT2.1.0(3年前)中被删除


改用
com.google.gwt.http.client.RequestBuilder

好的,这就是原因。好的,这就是原因。