当前位置: 代码迷 >> J2EE >> struts2和dwr共存有关问题
  详细解决方案

struts2和dwr共存有关问题

热度:152   发布时间:2016-04-22 02:55:06.0
struts2和dwr共存问题
被struts2过滤器过滤后, 不能成功跳转dwr 测试页, 3个XML文件主要如下:

web.xml:
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>activeReverseAjaxEnabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>initApplicationScopeCreatorsAtStartup</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>maxWaitAfterWrite</param-name>
<param-value>-1</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>


<filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>


<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>



dwr.xml

<dwr>
  <allow>
  <create javascript="UserAjax" creator="new">
  <param name="class" value="com.dwrdemo.view.UserAjax"></param>
  </create>
  <create javascript="TestAjax" creator="new">
  <param name="class" value="com.dwrdemo.view.TestAjax"></param>
  </create>
  <!-- this is a bad idea for live, but can be useful in testing -->
  <convert converter="exception" match="java.lang.Exception"/>
  <convert converter="bean" match="java.lang.StackTraceElement"/>
  <convert match="com.dwrdemo.dao.UserDao" converter="bean"></convert>
  </allow>
</dwr>


struts.xml:

<struts>
  <constant name="struts.enable.DynamicMethodInvocation" value="false" />
  <constant name="struts.devMode" value="false" />
  <constant name="struts.action.excludePattern" value="/dwr/*,/dwr/test/*"/>
  <package name="default" namespace="/" extends="struts-default">
  <default-action-ref name="index" />
  <action name="index">
  <result>/index.jsp</result>
  </action>
  </package>
</struts>


各位大侠帮帮忙呀!!!

------解决方案--------------------
Java code
  <filter-mapping>  <filter-name>struts2</filter-name>  <url-pattern>/*</url-pattern>  </filter-mapping>
------解决方案--------------------
哥遇上了和LZ一样的问题,正在寻求解决办法
------解决方案--------------------
  相关解决方案