Where to place business logic within spring mvc?

I do not know where to put the business logic in mvc spring, because I am new to this. I have an idea of ​​what to do, but due to lack of knowledge of spring, I do not know where to start. I would also like to ask if anyone knows where I can get a good tutorial on this or a complete Spring mvc web application example that has business logic on it? In any case, the business logic that I talked about is related to database processing :)

+22
source share
3 answers

@Controllerclasses serve C from MVC . Note that the real controller is in Spring MVC DispatchServlet, which will use a specific class @Controllerto process the request URL.

@Serviceclasses should serve your level of service. Here you should put your business logic .

@Repositoryclasses should serve for your level of data access. Here you must place the CRUD logic: insert, update, delete, select.

@Service, @RepositoryAnd your classes are essential M from the MVC . JSP and other viewing technologies (e.g. JSP, Thymeleaf, etc.) will match V from MVC .

@Controller @Service . @Service @Service @Repository .

+60

- . , , : , , , , , .

, - : - Spring

, , - .

+11

, - . pojos JSR.

Spring MVC , HTTP-, , -. DAO. , .

. - . .

0

Source: https://habr.com/ru/post/1673679/


All Articles