spring+springmvc+mybatis的配置文件
来源:互联网 发布:centos 7.3安装nginx 编辑:程序博客网 时间:2024/06/05 02:02
web.xml文件配置ssm
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <!-- 1.监听,数据库配置spring-mybatis.xml --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mybatis.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 2.spring-mvc。xml,web容器包含spring --> <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:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- 3.字符编码,utf-8 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
spring-mvc.xml配置源码
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd "> <!-- 扫描包 --> <context:component-scan base-package="com.aaa.controller"></context:component-scan> <!-- 注解 --> <mvc:annotation-driven/> <!--视图解析器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" > <property name="prefix" value="/"></property> <property name="suffix" value=".jsp"></property> </bean></beans>
spring-mybatis.xml 配置<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
">
<!-- 扫描包 -->
<context:component-scan base-package="com"></context:component-scan>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"></property>
<property name="username" value="scott"></property>
<property name="password" value="tiger"></property>
</bean>
<!-- 3.sqlSessionFactory工厂,加上mapper文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/><!-- classpath代表src -->
<property name="mapperLocations" value="classpath:com/aaa/mapper/*.xml"></property>
</bean>
<!-- 4.扫描与*mapper.xml对应的接口包 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
<property name="basePackage" value="com.aaa.dao"></property>
</bean>
<!-- 配置事务 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- 加载数据源 -->
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 开启事务扫描 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
阅读全文
1 0
- spring+springmvc+mybatis的配置文件
- spring+springMVC+mybatis的配置文件和包
- Spring+SpringMVC+MyBatis整合配置文件的搭建
- Maven+Spring+SpringMVC+Mybatis的配置文件
- Spring+SpringMVC+Mybatis基本配置文件
- spring+springmvc+mybatis整合配置文件
- springmvc配置文件:spring-mybatis.xml
- Spring+SpringMvc+Mybatis配置文件解读
- springmvc+mybatis 的配置文件
- SSM(Spring+SpringMVC+Mybatis)的配置文件的搭建
- 浅谈spring+springMVC+mybatis框架整合(配置文件的使用)
- Spring ,Springmvc,mybatis三大框架整合的配置文件支持
- spring + springmvc +mybatis 搭建 maven 项目的核心配置文件
- 整合SpringMVC+Spring+Mybatis+mysql的maven配置文件pom.xml
- spring/springmvc/spring+hibernate(mybatis)配置文件
- SSM整合配置文件(Springmvc+Spring+Mybatis)
- SSM(spring+mybatis+springmvc)整合 配置文件
- SSM整合配置文件(Springmvc+Spring+Mybatis)
- hdu 6073 Matching In Multiplication(2017 Multi-University Training Contest
- 【最短路入门专题1】 hdu 1874 B
- 易贝云网站管理系统 1.7.0 企业版
- Python---初识Scrapy框架
- VS 解决This function or variable may be unsafe
- spring+springmvc+mybatis的配置文件
- 武汉公布304个可售楼盘名单,保证供应稳定市场预期(蚌埠华瑞房地产评估)
- hdoj 6071 Lazy Running
- lua 出现 xxx: attempt to call a nil value (field 'getn') 解决办法
- OpenCV学习之利用Camshift算法进行彩色目标的跟踪
- VSCode安装Python智能插件
- CommandError: Target database is not up-如何解决
- php 百度地图 腾讯地图 转换坐标
- JSP中的JavaBean的基本使用方法