0

GWT と spring4gwt のチュートリアルに従い、次の構成で StockWatcher のデモを Spring(3.0) 対応サービスに変換することに成功しました。

web.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"/>

次に、別の Service: Chatroom.gwt.xml (rename-to="chatroom") を追加し、2 つのサービスを 1 つの webapp に結合して、1 つの 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>

ここで問題が発生します。springGwtRemoteServiceServlet が /stock/spring/* と /chatroom/spring/* を同時にリッスンできるようにする正しい URL パターンを記述する方法がわかりません。

StockWatcher モジュールは rename-to="stock" であるため、各 POST リクエストは URI "/stock/..." に投稿されます。Chatroom モジュールは rename-to="chatroom" で、各 POST は URI "/chatroom/..." に投稿されます。私は書いてみまし/*/spring/*たが、無駄に、両方とも動作しません...

4

2 に答える 2

2

/*/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 に答える