我是 GWT 的新手,我的 Web 应用程序没有任何结果。
当我尝试调试时,出现“找不到源”之类的错误
这是所有项目中编写的代码
<---------------------------------------------------- ---------------------------------------------------->
入口点类
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);
}
}
<---------------------------------------------------- ---------------------------------------------------->
服务接口
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();
}
<---------------------------------------------------- ---------------------------------------------------->
服务异步
package body.test.combo.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface FileReaderServiceAsync {
void readMyFilePlease(AsyncCallback<String> callbackVariable);
}
<---------------------------------------------------- ---------------------------------------------------->
服务器实现类
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;
}
}
<---------------------------------------------------- ---------------------------------------------------->
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>
项目名称是“组合”。