35.2. Spring MVC Integration

RESTEasy can also integrate with the Spring DispatcherServlet. This is advantageous because the web.xml is simpler, you can dispatch to either Spring controllers or RESTEasy from under the same base URL, and you can use Spring ModelAndView objects as return arguments from @GET resource methods. To set this up, you must use the Spring DispatcherServlet in your web.xml file, and import the springmvc-resteasy.xml file into your base Spring beans xml file. Here is an example web.xml file:
<web-app>
   <display-name>Archetype Created Web Application</display-name>

   <servlet>
      <servlet-name>Resteasy</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet;</servlet-class>
   </servlet>

   <servlet-mapping>
      <servlet-name>Spring</servlet-name>
      <url-pattern>/*</url-pattern>
   </servlet-mapping>


</web-app>
Then, within your main Spring beans xml file, import the springmvc-resteasy.xml file.
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
">

    <!-- Import basic SpringMVC Resteasy integration -->
    <import resource="classpath:springmvc-resteasy.xml"/>
....