Skip to content

Instantly share code, notes, and snippets.

@mazhar266
Last active March 2, 2019 17:29
Show Gist options
  • Save mazhar266/09fc40f0aea5ea10a45c05733e4932ca to your computer and use it in GitHub Desktop.
Save mazhar266/09fc40f0aea5ea10a45c05733e4932ca to your computer and use it in GitHub Desktop.
Sprint MVC Basic Infos

In Spring MVC uses a layered architecture

controllers > services > repositories > models > database.

Controllers

hold the presentation (UI) logic – process user request (GET / POST / other), prepare data for the view and render the view (or redirect to another URL). Example: prepare and show the home page.

Services

hold the business logic. Often just call some repository method. Example: create new post / show a post for deleting / delete post. Services may have several implementations: DB based or stub based.

Repositories

implement the database CRUD operations (create / read / edit / delete) in the database for certain entity class (model). Examples: find post by id / delete post by id. Often provided by the framework (not written by hand).

Models (entity classes)

holds the data about the application data. Examples: user, post, tag, …

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment