资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

使用spring如何实现springmvc与mybatis进行整合

使用spring如何实现springmvc与mybatis进行整合?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

成都创新互联公司是一家专业提供东宁企业网站建设,专注与网站设计制作、成都网站制作H5场景定制、小程序制作等业务。10年已为东宁众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。

1.jar包 

2.引入web.xml文件


    contextConfigLocation
    classpath:applicationContext.xml
  
  
    org.springframework.web.context.ContextLoaderListener
  
  
    springmvc
    org.springframework.web.servlet.DispatcherServlet
    
      contextConfigLocation
      classpath:springmvc.xml
    
  

  
    springmvc
    *.action

3.创建实体类

4.引入一个(类名)dao.xml


    update accounting set money=#{money} where name=#{name}
  
  

5.创建一个(类名)dao

public void update(Accounting a);
public Accounting findMoneyByName(String name);

6.写service

public void remit(String from,String to,double money);

7.写serviceimpl

@Service
public class AccountServiceImpl implements AccountService {
  @Autowired
  private AccountDao ad;
  @Override
  public void remit(String from, String to, double money) {
    Accounting fromAccount=ad.findMoneyByName(from);
    fromAccount.setMoney(fromAccount.getMoney()-money);
    ad.update(fromAccount);
    Accounting toAccount=ad.findMoneyByName(to);
    toAccount.setMoney(toAccount.getMoney()+money);
    ad.update(toAccount);
  }

}

8.引入applicationContext.xml



  
  
  

  
    
    
    
    
    
    
  
  
  
    
    
    
    
  


  
    
  
  
    
      
    
  
  
    
  


  
  
    
    
    
  

9.引入db.properties文件和log4j.properties文件

10.引入springmvc.xml文件


  
  
  

11.jsp页面编写

//index.jsp:
 
汇款人: 收款人: 钱数:
//message.jsp ${message }

关于使用spring如何实现springmvc与mybatis进行整合问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。


网站标题:使用spring如何实现springmvc与mybatis进行整合
网站链接:http://cdkjz.cn/article/pishhi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220