开发者

How to organize general purpose Spring controller functions?

开发者 https://www.devze.com 2023-04-01 20:01 出处:网络
I know that many people suggest grouping Spring controllers by page, i.e. \"LoginPageController\" and \"LandingPageController,\" etc. So the GET handler and other request handlers for the login page a

I know that many people suggest grouping Spring controllers by page, i.e. "LoginPageController" and "LandingPageController," etc. So the GET handler and other request handlers for the login page are in LoginPageController.

I like this organization most of the time, but lately I'm adding more AJAX functionality, some of which can be reused across many pages and isn't necessarily tied to a si开发者_高级运维ngle page. I'm wondering what other people are doing in this situation. Maybe make a package for general purpose controllers and try to categorize them in there?

Any advice would be great!


I prefer to group by function. Given your example, I would have a ProjectController that handles both the pages related to Projects as well as the Ajax calls that get/update project data.

0

精彩评论

暂无评论...
验证码 换一张
取 消