DAO calls from the JSP complies the MVC pattern?

This question already has an answer here:

  • How to avoid Java code in JSP files? 28 answers

  • From the design point of view, the solution (2) is better. Your DAO object may not be necessary the same with your presentation object, the model for your user interface. It can be even composed of more DAO objects.


    Its wrong practice to make DAO calls from JSP, According to MVC pattern , you should use JSP as a View, there will be a model consisting of getters and setters ie java POJO class. Also there will be a controller - a component which is responsible for communication between model and view.
    A user always sees the view and communicates with the controller. The values entered by user will be submitted from the view and are set to the model, which in turn will be used by the controller in backend.


    For that kind of operation you must use the JSTL functions. For jsp, as the previous comment explains it must have a view behavior. Explore how to use it, it is clean and simple to use.

    链接地址: http://www.djcxy.com/p/76614.html

    上一篇: Java,OpenOffice,将获取文档创建为jsp响应作为pdf

    下一篇: 来自JSP的DAO调用符合MVC模式?