Announcement Announcement Module
No announcement yet.
Servlet and URL Mapping doubts - HTTP 404 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Thank you

    Dear Enrico.

    As I said in the beginning, I am quite new to Spring, but I am not new to programming and also I don't think I am that far from getting it working. So you don't need to go on forever, really.

    I am not asking lightly, I have read enough and I try to understand things instead of just hitting ctrl+c, ctrl+v... What I am doing, as you said, is a complex thing and that's why I am asking here. If it was easy I'd probably manage myself.

    Thank you anyway for taking the time of answering.


    • #17
      I think this answers my doubts about component-scanning:

      I have advanced quite a lot, I have succesfully configured a test project and now @Controllers get scanned and they respond to the URL specified in @RequestMapping("/whatever").

      However there are still a few things I don't get. As Enrico said, I probably should investigate a bit more about "the concept of separation between core Spring config loaded with listener and Spring web mvc config loaded with DispatcherServlet context-param", which may be preventing my target project from serve both the original Web Services and the [email protected] URL's.

      Thank you,

      Last edited by Moonwalker; Aug 20th, 2010, 02:34 AM.


      • #18
        It is quite simple actually. When using Spring in a web application, you will have one CORE context containing everything non servlet-related (everything that is not web related: services, daos, pojos, aspects etc). This context is loaded by adding the following in web.xml:

        Then, you will have one more context for each Spring servlet you load in web.xml, for example if you use DispatcherServlet (Spring's web mvc):

        You will need one more context since you are also using Spring's web services.

        What about relations between those context? Well the core context will be at the disposal of every other servlet-loaded context. This means, for example, that you can inject and use core beans like services and daos inside your controllers.
        On the other hand, the reverse is not true: you can't inject beans from your web mvc context inside your core context, but why should you do something like that really? It's controllers that call services and not vice-versa!
        Also, your servlet context won't interact with each other, so, for example, you can't inject a controller inside a web service or vice-versa (again, why would you ever need to do something like that?)

        Hope I was clear enough...


        • #19

          Thank you Enrico, what you said sounds good to me. But maybe I could do it better by serving my Web Services using Spring MVC annotations, couldn't I?

          Our services are SOAP based -not REST-, so I don't know yet if it's supported.

          Spring 3.0 REST services are explained quite well here:

          (not my goal but maybe someone was after it).



          • #20
            ...and SOAP Spring Web Services, here:



            • #21
              Of course you can configure mvc in your web services context, that is perfectly fine. Just be aware that configuration you do in your dispatcherservlet context won't be available in the other one (they are two different contexts after all) so you must put scanning directives in both config files for example. What won't work is just direct injection between beans of different servlet contexts, because they are independent from one another, but that don't mean you can't configure them both as you like (althought the motivation behind usage of web mvc specific annotations in web services seems to slip my grasp, maybe I need to read something about Spring web services to get a clearer idea).

              Say hi to beautiful Barcelona for me.