详解spring+springmvc+mybatis整合注解

网友投稿 252 2023-05-20


详解spring+springmvc+mybatis整合注解

每天记录一点点,慢慢的成长,今天我们学习了ssm,这是我自己总结的笔记,大神勿喷!谢谢,主要代码!! !

spring&springmvc&mybatis整合(注解)

1.jar包

2.引入web.xml文件

contextConfigLocation

classpath:applicationContext.xml

org.springframework.web.context.ContextLoaderListener

springmvc

org.springframework.web.servlet.DispatcherServlet

<init-param>

contextConfigLocation

classpath:springmvc.xml

springmvc

*.action

3.创建实体类

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

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

select * from accounting 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

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:mvc="http://springframework.org/schema/mvc"

xmlns:context="http://springframework.org/schema/context"

xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.ohttp://rg/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-3.2.xsd

http://springframework.org/schema/mvc

http://springframework.org/schema/mvc/spring-mvc-3.2.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context-3.2.xsd

http://springframework.org/schema/aop

http://springframework.org/schema/aop/spring-aop-3.2.xsd

http://springframework.org/schema/tx

http://springframework.org/schema/tx/spring-tx-3.2.xsd ">

destroy-method="close">

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:mvc="http://springframework.org/schema/mvc"

xmlns:context="http://springframework.org/schema/context"

xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.ohttp://rg/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-3.2.xsd

http://springframework.org/schema/mvc

http://springframework.org/schema/mvc/spring-mvc-3.2.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context-3.2.xsd

http://springframework.org/schema/aop

http://springframework.org/schema/aop/spring-aop-3.2.xsd

http://springframework.org/schema/tx

http://springframework.org/schema/tx/spring-tx-3.2.xsd ">

destroy-method="close">

destroy-method="close">

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

10.引入springmvc.xml文件

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:mvc="http://springframework.org/schema/mvc"

xmlns:context="http://springframework.org/schema/context"

xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.org/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-3.2.xsd

http://springframework.org/schema/mvc

http://springframework.org/schema/mvc/spring-mvc-3.2.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context-3.2.xsd

http://springframework.org/schema/aop

http://springframework.org/schema/aop/spring-aop-3.2.xsd

http://springframework.org/schema/tx

http://springframework.org/schema/tx/spring-tx-3.2.xsd ">

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:mvc="http://springframework.org/schema/mvc"

xmlns:context="http://springframework.org/schema/context"

xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.org/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-3.2.xsd

http://springframework.org/schema/mvc

http://springframework.org/schema/mvc/spring-mvc-3.2.xsd

http://springframework.org/schema/context

http://springframework.org/schema/context/spring-context-3.2.xsd

http://springframework.org/schema/aop

http://springframework.org/schema/aop/spring-aop-3.2.xsd

http://springframework.org/schema/tx

http://springframework.org/schema/tx/spring-tx-3.2.xsd ">

11.jsp页面编写

//index.jsp:

汇款人:

收款人:

钱数:

//message.jsp

${message }


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:利用Vue v
下一篇:详解Vue 普通对象数据更新与 file 对象数据更新
相关文章

 发表评论

暂时没有评论,来抢沙发吧~