CRM 시스템

4742 단어
거래처
다오층
@Repository
public class CustomerDaoImpl implements ICustomerDao {

    @Autowired
    private HibernateTemplate template;//    ,    

    @Override
    public int save(Customer customer) {
        return (int) template.save(customer);
    }

    @Override
    public List findByExample(Customer example, int pageNum) {
        return template.findByExample(example, (pageNum - 1) * Const.PAGE_SIZE, Const.PAGE_SIZE);
    }

    @Override
    public int count(Customer cust) {
        List list = template.findByExample(cust);
        return list.size();
    }
}

서비스 계층
@Service
public class CustomerServiceImpl implements ICustomerService {
    @Autowired
    private ICustomerDao customerDao;

    public Page findByExample(Customer customer, int pageNum) {
        //    
        List list = customerDao.findByExample(customer, pageNum);
        //    
        int count = customerDao.count(customer);
        //   page
        return new Page(list, pageNum, count);
    }
}

액션 레이어
@Namespace("/") //    
@ResultPath("/jsp/customer") //            
@Component //spring  action
@Scope("prototype") //  ,action     
public class CustomerAction implements ModelDriven {//        
    @Autowired
    private ICustomerService customerService;

    private Customer customer = new Customer();//             

    private int pageNum = 1;//    ,     

    //  action
    @Action(value = "list", results = { @Result(name = "success", location = "list.jsp") })
    public String list() throws IOException {
        Page page = customerService.findByExample(customer, pageNum);
        ActionContext.getContext().put("page", page);//         
        return null;
    }

    //set、get  

}

applicationContext.xml

    
    

    
    
        
        
        
        
    
    
    
        
        
        
            
                org.hibernate.dialect.MySQL5InnoDBDialect
                true
                true
                update
            
        
    

    
    
        
    
    
    

    
        
    


web.xml

        contextConfigLocation
        classpath:spring/applicationContext.xml
    
    
        org.springframework.web.context.ContextLoaderListener
    


    
        OpenSessionInViewFilter
        org.springframework.orm.hibernate5.support.OpenSessionInViewFilter
    
    
        OpenSessionInViewFilter
        /*
    

    
        struts2
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
    

    
        struts2
        /*
    

좋은 웹페이지 즐겨찾기