我想熟悉使用GWT API來創建基於Web的應用程序。我一直在關注GWT的一些教程,並且還沒有能夠進行RPC調用。從廣泛的角度來看問題,我的目標是做一個服務器調用來運行一系列我知道工作的數據庫測試(我測試過這個代碼)。GWT rpc失敗 - 基地址不是我所期望的
---編輯---
我覺得這裏的問題是,資源正在尋找在這裏: /MatesWeb/org.matesweb.Main/peopleService
時,我認爲這應該看這裏: /MatesWeb/peopleService
--- END_EDIT ---
這裏是信息和代碼,我覺得是相關的:
個- 使用NetBeans的
- 錯誤,我得到的是「/MatesWeb/org.matesweb.Main/PeopleService - 描述 - 請求的資源不可用。」
-GWT.getModuleBaseURL()返回:8080/MatesWeb/org.matesweb.Main/
在瀏覽器-URL是:8080/MatesWeb/
從web.xml文件
<servlet>
<servlet-name>peopleService</servlet-name>
<servlet-class>org.matesweb.server.PeopleServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>peopleService</servlet-name>
<url-pattern>/peopleService</url-pattern>
</servlet-mapping>
From PeopleService Service package org.matesweb.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("PeopleService")
public interface PeopleService extends RemoteService {
String[] saveGetPerson(String[] persInfo);
int runTests();
}
從PeopleServiceImpl 包org.matesweb.server;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.matesweb.client.PeopleService;
import org.matesweb.server.tests.DbTest;
class PeopleServiceImpl extends RemoteServiceServlet implements PeopleService {
@Override
public String[] saveGetPerson(String[] persInfo) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int runTests()
{
int retInt;
DbTest dbTest = new DbTest();
retInt = dbTest.runTests();
return retInt;
}
}
從PeopleServiceAsync
package org.matesweb.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface PeopleServiceAsync
{
void saveGetPerson(String[] persInfo, AsyncCallback<String[]> persInformation);
void runTests(AsyncCallback<Integer> retInt);
}
的任何想法什麼怎麼回事?
乾杯, 尼克
我試着改變它,它似乎沒有任何幫助。我認爲這裏的問題是這裏的資源正在尋找: /MatesWeb/org.matesweb.Main/peopleService 當我認爲它應該在這裏尋找: /MatesWeb/peopleService – nmio