gpt4 book ai didi

java - GWT 警告 : No file found for:/com. mycompany.project.ImageViewer/GreetingService

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:23:32 27 4
gpt4 key购买 nike

不要连接到服务器...这是上次gwt eclipse中的一个项目

在 gwt 中点击按钮:

greetServer(textToServer,
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
dialogBox
.setText("Remote Procedure Call - Failure");
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}

public void onSuccess(String result) {
dialogBox.setText("Remote Procedure Call");
serverResponseLabel
.removeStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});

我的 gwt 服务器:

    public String greetServer(String input) throws IllegalArgumentException {
// Verify that the input is valid.
if (!FieldVerifier.isValidName(input)) {
// If the input is not valid, throw an IllegalArgumentException back to
// the client.
throw new IllegalArgumentException(
"Name must be at least 4 characters long");
}

String serverInfo = getServletContext().getServerInfo();
String userAgent = getThreadLocalRequest().getHeader("User-Agent");

// Escape data from the client to avoid cross-site script vulnerabilities.
input = escapeHtml(input);
userAgent = escapeHtml(userAgent);

return "Hello, " + input + "!<br><br>I am running " + serverInfo
+ ".<br><br>It looks like you are using:<br>" + userAgent;
}

这是我的 gwt 服务:

@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
}

gwt serviseAsyn 文件:

public interface GreetingServiceAsync {
void greetServer(String input, AsyncCallback<String> callback)
throws IllegalArgumentException;
}


web xml

<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>kill.server.GreetingServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/hello123/greet</url-pattern>
</servlet-mapping>

<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Hello123.html</welcome-file>
</welcome-file-list>

点击按钮 - 服务器不返回值,因为找不到文件 - 为什么?

Jun 27, 2012 11:12:13 AM com.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /com.mycompany.project.ImageViewer/GreetingService

怎么办?

最佳答案

在您的 web.xml 文件中,您将服务映射为 /hello123/greet:

<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/hello123/greet</url-pattern>
</servlet-mapping>

虽然错误显示它正在尝试加载默认值 /modulename/serviceinterfacename,或/com.mycompany.project.ImageViewer/GreetingService。有两个选项可用:

  1. 更改 web.xml 条目以使用 RPC 接口(interface)期望的默认 url
  2. 将远程服务配置为从您的自定义路径加载

这两个主题都在 https://developers.google.com/web-toolkit/doc/latest/DevGuideServerCommunication 中进行了简要讨论。 ,以及其他 RPC 设置细节。

对于第二个选项,这通常是这样的:

MyServiceAsync service = GWT.create(MyService.class);
((ServiceDefTarget)service).setServiceEntryPoint("/hello123/greet");
service.methodName(...

关于java - GWT 警告 : No file found for:/com. mycompany.project.ImageViewer/GreetingService,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11230518/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com