国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|編程技術(shù)|正則表達(dá)式|

服務(wù)器之家 - 編程語言 - JAVA教程 - 詳解spring+springmvc+mybatis整合注解

詳解spring+springmvc+mybatis整合注解

2020-09-20 12:34White_Black007 JAVA教程

本篇文章主要介紹了詳解spring+springmvc+mybatis整合注解,詳細(xì)的介紹了ssm框架的使用,具有一定的參考價(jià)值,有興趣的可以了解一下

每天記錄一點(diǎn)點(diǎn),慢慢的成長(zhǎng),今天我們學(xué)習(xí)了ssm,這是我自己總結(jié)的筆記,大神勿噴!謝謝,主要代碼!! !

spring&springmvc&mybatis整合(注解)

1.jar包

2.引入web.xml文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:springmvc.xml</param-value>
    </init-param>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>*.action</url-pattern>
</servlet-mapping>

3.創(chuàng)建實(shí)體類

4.引入一個(gè)(類名)dao.xml

?
1
2
3
4
5
6
<update id="update" parameterType="accounting" >
    update accounting set money=#{money} where name=#{name}
  </update>
  <select id="findMoneyByName" parameterType="string" resultType="accounting">
    select * from accounting where name=#{name}
</select>

5.創(chuàng)建一個(gè)(類名)dao

?
1
2
public void update(Accounting a);
public Accounting findMoneyByName(String name);

6.寫service

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

7.寫serviceimpl

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.2.xsd ">
 
  <!-- 加載db.properties文件中的內(nèi)容,db.properties文件中key命名要有一定的特殊規(guī)則 -->
  <context:property-placeholder location="classpath:db.properties" />
  <!-- 配置數(shù)據(jù)源 ,dbcp -->
 
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="${jdbc.driver}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="maxActive" value="30" />
    <property name="maxIdle" value="5" />
  </bean>
  <!-- sqlSessionFactory -->
  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <!-- 數(shù)據(jù)庫連接池 -->
    <property name="dataSource" ref="dataSource" />
    <!-- 加載mybatis的全局配置文件 -->
    <property name="configLocation" value="classpath:sqlMapConfig.xml" />
  </bean>
 
 
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
  </bean>
  <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
      <tx:method name="*" propagation="REQUIRED"/>
    </tx:attributes>
  </tx:advice>
  <aop:config>
    <aop:advisor advice-ref="txAdvice" pointcut="execution(* service..*.*(..))"/>
  </aop:config>
 
 
  <!-- mapper掃描器 -->
  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <!-- 掃描包路徑,如果需要掃描多個(gè)包,中間使用半角逗號(hào)隔開 -->
    <property name="basePackage" value="dao"></property>
    <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
  </bean>
 
</beans>

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

10.引入springmvc.xml文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.2.xsd ">
  <mvc:annotation-driven></mvc:annotation-driven>
  <context:component-scan base-package="action"></context:component-scan>
  <context:component-scan base-package="service"></context:component-scan>
</beans>

11.jsp頁面編寫

?
1
2
3
4
5
6
7
8
9
//index.jsp:
 <form action="account_execute.action" method="post">
  匯款人:<input type="text" name="from"/>
  收款人:<input type="text" name="to"/>
  錢數(shù):<input type="text" name="money"/>
  <input type="submit"/>
 </form>
//message.jsp
${message }

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:http://blog.csdn.net/white_black007/article/details/70830635

延伸 · 閱讀

精彩推薦
  • JAVA教程Java項(xiàng)目中如何訪問WEB-INF下jsp頁面

    Java項(xiàng)目中如何訪問WEB-INF下jsp頁面

    這篇文章主要介紹了Java項(xiàng)目中如何訪問WEB-INF下jsp頁面,文章通過示例代碼和圖文解析介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,...

    大道之簡(jiǎn)3942020-08-06
  • JAVA教程Spring Boot MyBatis 連接數(shù)據(jù)庫配置示例

    Spring Boot MyBatis 連接數(shù)據(jù)庫配置示例

    本篇文章主要介紹了Spring Boot MyBatis 連接數(shù)據(jù)庫示例的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。...

    catoop2372020-08-19
  • JAVA教程Java String對(duì)象使用方法詳解

    Java String對(duì)象使用方法詳解

    這篇文章主要介紹了Java String對(duì)象使用方法詳解的相關(guān)資料,需要的朋友可以參考下...

    Java教程網(wǎng)1922020-09-19
  • JAVA教程java的if else語句入門指南(推薦)

    java的if else語句入門指南(推薦)

    下面小編就為大家?guī)硪黄猨ava的if else語句入門指南(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧 ...

    jingxian1572020-05-12
  • JAVA教程Java中的多態(tài)用法實(shí)例分析

    Java中的多態(tài)用法實(shí)例分析

    這篇文章主要介紹了Java中的多態(tài)用法,較為詳細(xì)的分析了java中多態(tài)的概念與相關(guān)的實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下 ...

    司青5462019-12-16
  • JAVA教程Mybatis接口式編程的原理

    Mybatis接口式編程的原理

    mybatis有兩種實(shí)現(xiàn)方式,一種可以通過xml配置文件實(shí)現(xiàn),其二是面向接口編程的實(shí)現(xiàn)。本文重點(diǎn)給大家介紹mybatis接口編程的原理,需要的的朋友參考下...

    Terence_Jing2722020-08-29
  • JAVA教程Java中的BufferedInputStream與BufferedOutputStream使用示例

    Java中的BufferedInputStream與BufferedOutputStream使用示例

    BufferedInputStream和BufferedOutputStream分別繼承于FilterInputStream和FilterOutputStream,代表著緩沖區(qū)的輸入輸出,這里我們就來看一下Java中的BufferedInputStream與BufferedOutp...

    kuiwu-wang3832020-05-19
  • JAVA教程java web個(gè)人通訊錄系統(tǒng)設(shè)計(jì)

    java web個(gè)人通訊錄系統(tǒng)設(shè)計(jì)

    這篇文章主要為大家詳細(xì)介紹了java web個(gè)人通訊錄系統(tǒng)設(shè)計(jì),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下 ...

    kang_ya_ping2962020-07-30
主站蜘蛛池模板: 爱操av| 日韩精品一区二区在线观看 | 久久久亚洲 | 久久成人一区 | 视频一区二区在线观看 | 日韩欧美国产一区二区 | 一级电影毛片 | 中国女人真人一级毛片 | 久久亚洲综合 | 精品久久久久久亚洲综合网 | 国产成年人电影在线观看 | 欧美黄页| 欧美精品久久久久久久久老牛影院 | 久久精品综合 | 欧美三级在线播放 | 日韩成人一区二区 | 国内精品久久久久 | 一区二区三区在线播放 | 亚洲综合精品 | 国产成人久久 | 亚洲欧美高清 | 不卡黄色片 | 亚洲国产一区二区三区日本久久久 | 免费看一级黄色片 | 精品久久99 | 久草中文在线 | 狠狠淫 | 高清日韩av | 一性一交一色生活片 | 精品久久久久久久久久 | 免费一级毛片免费播放 | 国产人久久人人人人爽 | 精品国产欧美一区二区 | 国色天香成人网 | 99视频网| 欧美大片免费观看 | 日韩www| 龙珠z国语版291集全 | 特黄特色一级片 | 久久视频精品 | 免费不卡视频 |