0

我成功地按照 GWT 和 spring4gwt 的教程,通过以下配置将 StockWatcher 的演示转换为启用 Spring(3.0) 的服务:

网页.xml:

  <servlet-mapping>
    <servlet-name>springGwtRemoteServiceServlet</servlet-name>
    <!-- stockWatcher module is rename-to="stock" -->
    <url-pattern>/stock/spring/*</url-pattern> 
  </servlet-mapping>

StockPriceService.java:

@RemoteServiceRelativePath("spring/stockPriceService")
public interface StockPriceService extends RemoteService
{
  StockPrice[] getPrices(String[] symbols) throws DelistedException;
}

春天的 app.xml :

<bean id="stockPriceService" class="destiny.gwt.stock.server.StockPriceServiceImpl"/>

然后,我想添加另一个服务:Chatroom.gwt.xml (rename-to="chatroom"),并希望这两个服务可以组合在一个 webapp 中并由一个 spring4gwt 实例提供服务。

这是我的 ChatService.java :

@RemoteServiceRelativePath("spring/chatService")
public interface ChatService extends RemoteService
{
  public boolean login(String username , String password);
}

春天的 app.xml :

  <bean id="chatService"       class="destiny.gwt.chatroom.server.ChatServiceImpl"/>
  <bean id="stockPriceService" class="destiny.gwt.stock.server.StockPriceServiceImpl"/>

至于 web.xml :

  <servlet-mapping>
    <servlet-name>springGwtRemoteServiceServlet</servlet-name>
    <url-pattern>/stock/spring/*</url-pattern>
  </servlet-mapping>

问题来了!我不知道如何编写正确的 url 模式让 springGwtRemoteServiceServlet 能够同时收听 /stock/spring/* 和 /chatroom/spring/* ?

StockWatcher 模块是 rename-to="stock" ,因此每个 POST 请求都将发布到 URI "/stock/..." 。聊天室模块是 rename-to="chatroom" ,每个 POST 都会被发布到 URI "/chatroom/..." 。我试图写/*/spring/*,但徒劳无功,两者都不起作用......

4

2 回答 2

2

该表达式/*/spring/*不是 spring 的有效路径。*您可以显式设置另一个映射,而不是尝试使用通配符 ( ):

<servlet-mapping>
  <servlet-name>springGwtRemoteServiceServlet</servlet-name>
  <url-pattern>/stock/spring/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
  <servlet-name>springGwtRemoteServiceServlet</servlet-name>
  <url-pattern>/chatroom/spring/*</url-pattern>
</servlet-mapping>
于 2011-11-22T19:54:09.170 回答
1

尝试这个:

<servlet-mapping>
    <servlet-name>springGwtRemoteServiceServlet</servlet-name>
    <url-pattern>/spring/*</url-pattern>
  </servlet-mapping>

接着:

@RemoteServiceRelativePath("../spring/chatService")
于 2010-12-10T16:14:36.007 回答