0
發送的HttpRequest從服務器端
我試圖讓HTTP請求到服務器從我的GWT應用試圖在GWT
下面是我使用的作品,從客戶端罰款代碼..
但我想從服務器端做..
如果我能爲
String url = "http://www.myserver.com/getData?type=3";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
try {
Request request = builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// Couldn't connect to server (could be timeout, SOP violation, etc.)
}
public void onResponseReceived(Request request, Response response) {
if (200 == response.getStatusCode()) {
// Process the response in response.getText()
} else {
// Handle the error. Can get the status text from response.getStatusText()
}
}
});
} catch (RequestException e) {
// Couldn't connect to server
}
一些參考的解決方案:www.gwtproject.org/doc/latest/DevGuideServerCommunication.html
你可以使用任何休息客戶端..就像apache-http那樣 – dhamibirendra