AnsweredAssumed Answered

Spring MVC Controllers vs. Webscripts

Question asked by mangar on Mar 30, 2014
Latest reply on Sep 21, 2016 by daniel.gradecak
I recently was able to add spring controllers to my Alfresco.  I just added this to my web.xml:

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

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


Added a springMVC-servlet.xml like this: (only important bits:

    <context:annotation-config />
    <context:component-scan base-package="org.xxx.alfresco.web"/>
    <mvc:annotation-driven />


and presto!  SpringMVC Controllers in my Alfresco.  I can even easily inject the registry, nodeservice, etc…. (Actually, the @Autowired annotation works so it's so easy and supercool.)

This seems A LOT simpler than the webscript framework.  More powerfull/flexible, I can do views/templates.  Yes I understand that I can do all of this in a webscript, but SpringMVC is SO much easier.

Now, I did a quick search on the internets and found nothing on this technique. Which makes me think one of 3 things: (in ascending order of likelihood)

1. I am a ground breaking genius.
2. This is obvious, been done many times, and so simple no tutorials are necessary. 
3. There is something horribly wrong with this technique.

I assume that it is #3, but what do you think?

Any feedback would be greatly appreciated.

Outcomes