多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > 06_MyBatis,Spring,SpringMVC整合

06_MyBatis,Spring,SpringMVC整合

來源:程序員人生   發布時間:2015-01-28 09:05:25 閱讀次數:4085次

  1. 項目結構

  1. Spring的配置:

beans.xml

<?xml version="1.0" encoding="UTF⑻"?>

<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⑶.0.xsd

       http://www.springframework.org/schema/mvc

       http://www.springframework.org/schema/mvc/spring-mvc⑶.0.xsd

       http://www.springframework.org/schema/context

       http://www.springframework.org/schema/context/spring-context⑶.0.xsd

       http://www.springframework.org/schema/aop

       http://www.springframework.org/schema/aop/spring-aop⑶.0.xsd

       http://www.springframework.org/schema/tx

       http://www.springframework.org/schema/tx/spring-tx⑶.0.xsd ">                      

      

       <context:component-scan base-package="com.rl"/>

      

       <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

           <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>

           <property name="url" value="jdbc:mysql://localhost:3306/mybatis"></property>

           <property name="username" value="root"></property>

           <property name="password" value="123456"></property>

       </bean>

      

       <!--

           使用spring來管理sqlSessionFactory

        -->

       <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

           <property name="configLocation" value="classpath:sqlMapConfig.xml"></property>

           <property name="dataSource" ref="dataSource"></property>

       </bean>

      

       <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

           <property name="dataSource" ref="dataSource"></property>

       </bean>

      

       <tx:advice id="txAdvice" transaction-manager="txManager">

           <tx:attributes>

              <tx:method name="save*" propagation="REQUIRED"/>

              <tx:method name="update*" propagation="REQUIRED"/>

              <tx:method name="delete*" propagation="REQUIRED"/>

              <tx:method name="select*" read-only="true"/>

           </tx:attributes>

       </tx:advice>

      

       <aop:config>

           <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.rl.service..*.*(..))"/>

       </aop:config>

</beans>

  1. springmvc.xml的配置內容以下:

<?xml version="1.0" encoding="UTF⑻"?>

<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⑶.0.xsd

       http://www.springframework.org/schema/mvc

       http://www.springframework.org/schema/mvc/spring-mvc⑶.0.xsd

       http://www.springframework.org/schema/context

       http://www.springframework.org/schema/context/spring-context⑶.0.xsd

       http://www.springframework.org/schema/aop

       http://www.springframework.org/schema/aop/spring-aop⑶.0.xsd

       http://www.springframework.org/schema/tx

       http://www.springframework.org/schema/tx/spring-tx⑶.0.xsd ">                       

      

       <context:component-scan base-package="com.rl.controller"/>

       <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">

           <property name="prefix" value="/WEB-INF/jsp/"></property>

           <property name="suffix" value=".jsp"></property>

       </bean>

</beans>

  1. web.xml的配置內容以下:

      <?xml version="1.0" encoding="UTF⑻"?>

      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

          id="WebApp_ID" version="2.5">

         

          <listener>

             <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

          </listener>

          <context-param>

             <param-name>contextConfigLocation</param-name>

             <param-value>classpath:beans.xml</param-value>

          </context-param>

         

          <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>*.do</url-pattern>

          </servlet-mapping>

         

          <filter>

              <filter-name>SpringCharacterEncodingFilter</filter-name>

              <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>

              <init-param>

      生活不易,碼農辛苦
      如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
      程序員人生

      ------分隔線----------------------------
      分享到:
      ------分隔線----------------------------
      關閉
      程序員人生
      主站蜘蛛池模板: 欧美一级精品高清在线观看 | 美女无遮挡免费视频网站 | 亚洲人成77777在线播放网站不卡 | 国产亚洲毛片在线 | 亚洲 校园 欧美 动漫 制服 | 91嫩草私人成人亚洲影院 | 欧美永久免费 | jizz日本老师 | 日本肥老太成熟 | 欧美一区二区二区 | 日韩中文精品亚洲第三区 | 亚洲第99页 | 亚洲精品一区二区三区中文字幕 | 伊人久久大香线蕉亚洲 | 三级国产短视频在线观看 | 久久精品国产亚洲网址 | 亚洲免费色视频 | 欧美最猛性xxxxx短视频 | 久久久久久极精品久久久 | 久久久久综合网久久 | 伊人五月在线 | 国产黄色在线网站 | 国产精品亚洲欧美大片在线看 | 最近中文字幕2019免费版日本 | 欧美激情久久久久久久大片 | 黑人群姣中国妞在线观看 | 精品国产影院 | 中文字幕校园春色 | 免费国产h视频在线观看 | 性videos另类hd | 日产精品一区二区三区免费 | 国产精品亚洲一区二区三区正片 | 国产日韩欧美综合一区 | 欧美v亚洲 | 日韩免费一区二区三区 | 狠狠色噜噜狠狠狠狠五月婷 | 欧美成视频 | 亚洲在线综合 | 亚欧成人在线 | 国产亚洲综合激情校园小说 | 在线观看视频中文字幕 |
      <sub id="riian"><optgroup id="riian"><div id="riian"></div></optgroup></sub>