Guice和GWT问题-can';找不到GWT.rpc
我用简单的服务构建了一个简单的联系人管理器应用程序,它确实起了作用。 然后我决定使用Guice来管理我的服务和实现。 我还将mvp4g插件用于MVP设计模式。 我跟踪了Eric Burke的exmaple,我的代码如下:Guice和GWT问题-can';找不到GWT.rpc,gwt,mvp,guice,gwt-rpc,Gwt,Mvp,Guice,Gwt Rpc,我用简单的服务构建了一个简单的联系人管理器应用程序,它确实起了作用。 然后我决定使用Guice来管理我的服务和实现。 我还将mvp4g插件用于MVP设计模式。 我跟踪了Eric Burke的exmaple,我的代码如下: ContactService.java @RemoteServiceRelativePath("GWT.rpc") public interface ContactService extends RemoteService { public void save
ContactService.java
@RemoteServiceRelativePath("GWT.rpc")
public interface ContactService extends RemoteService {
public void saveContact(Contact c);
public List<Contact> listContacts();
}
MyGuiceContextListener.java
public class MyGuiceContextListener extends GuiceServletContextListener {
@Override
protected Injector getInjector() {
return Guice.createInjector(new ContactServletModule());
}
}
但当我启动应用程序并尝试通过调用listContacts()列出联系人时,tomcat告诉我找不到GWT RPC(确切地说:请求的资源(/YuriContactManager/org.yuri.ContactManager/GWT.RPC)不可用。)我的web.xml如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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">
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.yuri.server.MyGuiceContextListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>welcomeGWT.html</welcome-file>
</welcome-file-list>
</web-app>
guiceFilter
com.google.inject.servlet.GuiceFilter
guiceFilter
/*
org.yuri.server.MyGuiceContextListener
welcomeGWT.html
任何人都有类似的问题,或者知道可能有什么问题吗?在ContactServletModule中发现错误:)服务路径需要修改为“/org.yuri.YuriContactManager/GWT.rpc”-我想原因是我也在使用mvp4g框架,但我不确定
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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">
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.yuri.server.MyGuiceContextListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>welcomeGWT.html</welcome-file>
</welcome-file-list>
</web-app>