我正在嘗試將彗星聊天整合到我的struts2 + hibernate應用程序中。首先我已經在單獨的web應用程序中測試了彗星聊天。它工作正常.Ihave從http://skillshared.blogspot.in/2012/10/facebook-similar-chat-for-your-java-web.html下載它,然後後,我嘗試在我的應用程序中實現Struts2和Comet url模式衝突
在這裏,我在web.xml的問題是我的web.xml文件
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<display-name>Cometd Test WebApp</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Portability Filter, needed only to run on non Jetty
or non Servlet-3.0 containers like Tomcat-->
<filter>
<filter-name>continuation</filter-name>
<filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>continuation</filter-name>
<url-pattern>/cometd/*</url-pattern>
</filter-mapping>
<!-- Cometd Servlet -->
<servlet>
<servlet-name>cometd</servlet-name>
<servlet-class>org.cometd.annotation.AnnotationCometdServlet</servlet-class>
<init-param>
<param-name>timeout</param-name>
<param-value>20000</param-value>
</init-param>
<init-param>
<param-name>interval</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>maxInterval</param-name>
<param-value>10000</param-value>
</init-param>
<init-param>
<param-name>maxLazyTimeout</param-name>
<param-value>5000</param-value>
</init-param>
<init-param>
<param-name>long-polling.multiSessionInterval</param-name>
<param-value>2000</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>transports</param-name>
<param-value>org.cometd.websocket.server.WebSocketTransport</param-value>
</init-param>
<init-param>
<param-name>services</param-name>
<param-value>com.semika.cometd.ChatService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cometd</servlet-name>
<url-pattern>/cometd/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
從上面的代碼的應用程序工作正常,但聊天不工作。我看到關於這個問題,所以文章中,我有一個解決方案
<URL-pattern>*.action</URL-pattern>
當我試圖做到這一點的聊天工作正常,但應用程序無法正常工作。當我有地方應用程序只工作。
<url-pattern>/*</url-pattern>
我在struts.xml中試過這個,但沒用。
<constant name="struts.action.excludePattern" value="/cometd/*,/cometd/.*"/>
問題的原因是什麼?
謝謝你的建議,現在工作得很好。 –