需要访问相同URL模式的不同Servlet映射

时间:2018-10-08 12:18:05

标签: url-pattern servlet-mapping

我正在同一项目中使用2个不同的框架(Struts和spring),并且可以正常工作,但是由于web.xml中的url模式相同,因此无法映射到不同的servlet映射。您能帮我映射到其他servlet映射吗?

找到下面的代码

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
<!-- 
  ===== ContextLoaderListener ================================================= 
  -->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <!-- Spring 
  ===== <servlet> definitions ==================================================-->
<servlet>
  <servlet-name>dispatcher</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/conf/spring/spring-config.xml</param-value>
   </init-param>
  <load-on-startup>1</load-on-startup>  
</servlet>  
<servlet-mapping>
  <servlet-name>dispatcher</servlet-name>
  <url-pattern>*.html</url-pattern>
</servlet-mapping> 
  <!-- Struts
  ===== <servlet-mapping> definitions ==========================================-->
<servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
  <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/conf/struts-config.xml</param-value>
  </init-param>
  <load-on-startup>0</load-on-startup>  
</servlet>
</web-app>

0 个答案:

没有答案