Where to put business logic in spring mvc framework?

后端 未结 3 973
别跟我提以往
别跟我提以往 2020-12-23 10:12

I don\'t know where to put the business logic in spring mvc because I\'m new to it. I have a clue on what to do but because of lack in knowledge in spring mvc, I don\'t know

3条回答
  •  死守一世寂寞
    2020-12-23 10:44

    Generally, your business logic goes in the service layer. Though you can put basic validation rules in your pojos with JSR annotations.

    For a Spring MVC app you have controllers, which handle http requests, and a domain layer, which are pojos representing your business models. You often have a persistence layer, or DAO. You might have a service layer as well, for helping with non-trivial logic.

    Your comment about database handling doesn't make sense. Business rules are orthogonal to storing data. Your database handling should go in your persistence layer.

提交回复
热议问题