MVC Confused about where to put logic.
So I am currently modelling a MVC type system, total noob to this pattern and I'm trying to figure out a couple of things but one thing particular I can't figure out how to handle.
In my system I create eg a Customer Class & DAO with CRUD functionality which I understand (to an extent ) etc...
I have a table in my database that log's data, this table is never accessed by the user only the extent that they can view calculations/results from the data in this table.
How do I represent this in my design, I have no need for CRUD functionality only just to return results from SQL (eg Select average/total/ etc).
I obviously need to access the data but I'm not sure if I need a class that models the table or just somewhere to put the logic.
Any help or pointers would be much appreciated
View (JSP or JSF that displays the Model) -> Service Layer (business code that starts the transaction, uses DAO etc, populates the Model) -> Data access layer (your doa and data mapper here) -> DB
NOTE: None of this requires Spring. Pure Java EE is more than enough.
If u want strict MVC then u must create class that represents your table, and dont access directly to table.
PS this class may contain only one method, that is ok.
You should use some framework to implement MVC, like Struts or Spring. For your scenario, Struts will be good and business logic should be in the normal java classes.
Front controller should send the request to model classes with business logic and tables should be implemented using Java Beans.
链接地址: http://www.djcxy.com/p/67108.html上一篇: 使用Node.js和旧的Java Web应用程序(Spring MVC)
下一篇: MVC混淆逻辑的放置位置。