DAO层,Service层,Controller层、View层

参考文档:http://blog.csdn.net/zdwzzu2006/article/details/6053006

对于我这种小菜鸟来说,觉得写得很好

想的时候是:前端---action---service(业务逻辑)---dao(数据访问)---database

写代码的时候是:database---dao---service---action/前端

其中,action就是代表了controller ?

例子:

(只看流程就可以了,不要管代码什么含义)

(1)在一个JSP页面看到

<c:forEach items="${lstDate}" var="lstDate" varStatus="status">
                        <tr>
                            <td>${status.index+1}</td>
                            <td>项目:</td>
                            <td class="lineSty3">${lstDate.xmmc}</td>
                            <td>阶段:</td>
                            <td class="lineSty3">${lstDate.xmjd}</td>
                           
                        </tr>
                    </c:forEach>

它是要列举出来所有的lstDate集合里的xmmc、xmjd

(2)那么,lstDate是什么呢,接下来找到controller

List<Map<String, Object>> lstDate=proPeriodPlanService.findById();
        
model.addAttribute("lstDate",lstDate);

(3)接下来要去找service的findById()

public List<ProPeriodplan>  findById(String id) throws Exception;

(4)在service的Impl里实现

    @Override
    public List<ProPeriodplan> findById(String id) throws Exception {
        // TODO Auto-generated method stub
        return proPeriodPlanDao.findById(id);
    }

(5)看到它接着去找Dao

@Query(value = "From ProPeriodplan f where f.objProInfo.proId = ?1 order by f.objDicPeriod.perId asc")
    public List<ProPeriodplan> getPeriodplanById(String proId);
原文地址:https://www.cnblogs.com/Donnnnnn/p/5830441.html