我是GWT的新手,我的网络应用程序没有结果。
当我尝试调试时,出现了“源未找到”这样的错误
这是在所有项目中编写的代码
< --------------------------------------------- ------------------------------------------->
EntryPoint类
package body.test.combo.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
public class Combo implements EntryPoint {
private final FileReaderServiceAsync serviceAsync = GWT
.create(FileReaderService.class);
String content;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
VerticalPanel vPanel = new VerticalPanel();
serviceAsync.readMyFilePlease(new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
content = result;
}
@Override
public void onFailure(Throwable caught) {
System.out.println("Tezak");
}
});
Label lb = new Label(content);
vPanel.add(lb);
RootPanel.get().add(vPanel);
}
}
&LT; --------------------------------------------- -------------------------------------------&GT;
服务接口
package body.test.combo.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("readmeplease")
public interface FileReaderService extends RemoteService {
String readMyFilePlease();
}
&LT; --------------------------------------------- -------------------------------------------&GT;
服务异步
package body.test.combo.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface FileReaderServiceAsync {
void readMyFilePlease(AsyncCallback<String> callbackVariable);
}
&LT; --------------------------------------------- -------------------------------------------&GT;
服务器实施类
package body.test.combo.server;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import body.test.combo.client.FileReaderService;
public class FileReaderServiceImplementation extends RemoteServiceServlet implements FileReaderService {
@Override
public String readMyFilePlease() {
String allContent = "ezayak yad ya sayed";
return allContent;
}
}
&LT; --------------------------------------------- -------------------------------------------&GT;
Web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Servlets -->
<servlet>
<servlet-name>readMyFilePlease</servlet-name>
<servlet-class>body.test.combo.server.FileReaderServiceImplementation</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>readMyFilePlease</servlet-name>
<url-pattern>/combo/readmeplease</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Combo.html</welcome-file>
</welcome-file-list>
</web-app>
项目名称为'combo'。
答案 0 :(得分:0)
您的项目xml文件(Combo.gwt.xml)是否包含以下内容:
<module rename-to='combo'>
您可能还想尝试一下post中的一些建议。
发布该项目的xml文件以及错误本身非常有用。