Struts2拦截了Servlet的请求解决

最近在写一个程序采用的技术S2SH,其中有一块用在线支付平台,由于在线支付平台是很早写的采用的Servlet方式写的,

遇到的问题是在web.xml配置中又要配置Struts2,又要配置Servlet,配置如下:

<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>

 

<servlet>
  <display-name>
   This is the display name of my J2EE component
  </display-name>
  <servlet-name>PaymentRequest</servlet-name>
  <servlet-class>servlet.PaymentRequest</servlet-class>
 </servlet>
 <servlet>
  <display-name>
   This is the display name of my J2EE component
  </display-name>
  <servlet-name>PaymentResult</servlet-name>
  <servlet-class>servlet.PaymentResult</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>PaymentRequest</servlet-name>
  <url-pattern>/servlet/PaymentRequest</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
  <servlet-name>PaymentResult</servlet-name>
  <url-pattern>/servlet/PaymentResult</url-pattern>
 </servlet-mapping>

这样产生的一个结果是Struts2也把请求Servlet的url也拦截掉啦,就是说请求不到Servlet!

解决方法是修改Struts2的拦截方式:

 <filter-mapping>
  <filter-name>Struts2</filter-name>
  <url-pattern>*.action</url-pattern>
 </filter-mapping>
 <filter-mapping>
  <filter-name>Struts2</filter-name>
  <url-pattern>*.jsp</url-pattern>
 </filter-mapping>
 <filter-mapping>
  <filter-name>Struts2</filter-name>
  <url-pattern>/struts/*</url-pattern>
 </filter-mapping>

此问题做一备注,为后来者做一点参考!

你可能感兴趣的:(struts,servlet,url,平台)