Announcement Announcement Module
No announcement yet.
Difference between a Service and a Controller? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Difference between a Service and a Controller?


    I'm kind of new to Spring 3 MVC (am coming from a WebWorks/Struts 2 background) and am confused by the difference between a Service and a Controller. I tried looking through the Spring docs to see if I could find a clear definition of either, but cannot seem to find anything.

    It would appear to me that a Controller is the part that would handle an incoming request - akin to a Struts2 Action. However, it does not seem as "flexible" as the Action, and consequently, I figure that I must be either misunderstanding its purpose or how to use it. ie: in a Struts2 action, you specify the parameters that you are expecting with simple getters. From what I've seen with a Controller, you have to specify a parameter list and @RequestParameter annotations, which does not seem as clean.

    And then I am completely lost as to what the purpose of a Service is.

    If anyone could help me understand the difference, and their purposes, I would be grateful.



  • #2
    If you are talking about @controller and @service : These are simple stereotypes which will specify a java class as apart of a prsentation layer component and business layer component respectively.