国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

java - Should the service layer not write http-related operations?
給我你的懷抱
給我你的懷抱 2017-06-23 09:14:01
0
3
1104

Prerequisite: java, springmvc.

I have a service class of userService, which contains 2 methods to operate the current user, getCurrenUser and setCurrenUser.
But these two methods either obtain token from request, or read information from session.
The leader told me that the service layer should not write request related code,

Is this reasonable?
I personally believe that the service layer should only focus on logic and should not be strongly dependent on certain environments. but. . . Where should I write a class that operates CurrenUser?

給我你的懷抱
給我你的懷抱

reply all(3)
過去多啦不再A夢(mèng)

From your description, it seems that you want to use the request object in the Service layer to obtain the user information in the session.
I remember that the Spring framework can register a RequestContextListener, and then you can get the request through RequestContextHolder without passing it to the Service through the Controller. I seem to have used AOP in previous projects, but I can’t remember the details.
Also, I think, writing code depends on your mood, you can write how you want. :-)

我想大聲告訴你

I don’t know what you mean.
Just add a new one in the controller method.

黃舟

Yes, according to the post with the accepted answer, Baidu has published relevant articles.

http://blog.csdn.net/jiaobuch...

http://blog.csdn.net/u0127068...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template