views:

58

answers:

0

Hi,

I'm on a project that requires Spring-MVC for page navigation (possibly with webflow) where certain pages use RESTEasy to make Ajax calls (with JSON). I found an approach on DZone JavaLobby and followed it's approach (server is JBoss):

I have configured the project so that it uses Spring MVC for page navigation and REST calls as required, but, I'm uncomfortable with the way I've done it...the set up in the web.xml uses two request dispatchers.

The web.xml is as follows:

<servlet>
    <servlet-name>SpringFrontController</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet>
    <servlet-name>RestService</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc-servlet.xml</param-value>
        </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>RestService</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>SpringFrontController</servlet-name>
    <url-pattern>*.htm</url-pattern>
</servlet-mapping>

So this means I have a RestService-servlet.xml configured as described in the Dzone article above (sorry I couldn't post more than one link),

and a SpringFrontController-servlet.xml configured to scan my Spring MVC controller package for controllers.

So, is this approach (two request dispatchers) good design? Have I missed something in the Dzone guide above? If I drop one of the dispatcher mappings in the web.xml then the application doesn't work. As I loose mapping to my request dispatchers.

Any advice would be greatly appreciated. Mark.