I am creating an application were I am using MVC pattern.For this I am considering my view as jsps,controller as servlets and model as DAO objects.I have a doubt that me considering DAO objects as Model is right or wrong?
相关问题
- How to dynamically load partial view Via jquery aj
- passing a parameter to the link_to method
- Magic Suggest - Pre-select multiple items from MVC
- Servlet to jsp communication best practice
- Tutorials For Database-Driven Routing in Zend Fram
相关文章
- Forward request from servlet to jsp
- superclass mismatch for class CommentsController (
- play2 framework my template is not seen. : package
- How to catch exception in flutter?
- How to send AJAX data from VIEW to CONTROLLER? (PH
- Backbone fetching data from model vs collection
- How should I create model class to call API (Using
- Generate list in view and pass it to controller
Model is not a DAO. It is a layer, which contains all the domain logic, and is composed mostly from two types of elements, with following responsibilities:
The idea is that business logic should never be tied to the storage mechanism. When you are creating an invoice, the domain object should not care, if data comes from SQL database, MSWord document, remote REST API or just a mocked up data.
You might find this article interesting and relevant: GUI Architectures.
A model in MVC is where the business logic lives.
Looking at the sun Java EE pattern definitions we see that DAOs encapsulate persistence mechanisms and are used by a Business Object. I don't therefore see DAOs as natuarally having any business logic.
In simple systems, a few database tables, or those where the business logic is implemented in the database (stored procedures, referential integrity checks, triggers) then the DAO is effectively a facade in front of Business Logic, so they pretty much look like the Model. So in some introductory material you may see the DAO as pretty much the only Java expression of the Model.
When we choose to implement our business logic in Java, it would lie in a layer above the DAO, in for example Session Beans, which use the DAOs, and in my mind it's the Session Bean or equivalent which is the Model.
So ask yourself: where is the business logic? That's where the Model really is.