SSM配置文件
2020-06-19 14:24
47 查看
applicationContext.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: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.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!-- 扫描注解 --> <context:component-scan base-package="com.zhangzhilin"/> <!-- SpringMVC注解驱动 --> <mvc:annotation-driven/> <!-- 视图解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <!-- mybatis配置 --> <!-- 1.关联数据库配置文件 --> <context:property-placeholder location="classpath:jdbcConfig.properties"/> <!-- 2.连接池 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="DriverClass" value="${db.driver}"/> <property name="jdbcUrl" value="${db.url}"/> <property name="user" value="${db.username}"/> <property name="password" value="${db.password}"/> </bean> <!-- 3.sqlSessionFactory --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <!-- 绑定MyBatis的配置文件 --> <property name="configLocation" value="classpath:Mybatis-config.xml"/> </bean> <bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.zhangzhilin.mapper"/> </bean> </beans>
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- 配置pojo类的别名 --> <typeAliases> <package name="com.zhangzhilin.pojo"/> </typeAliases> </configuration>
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <!-- DispatchServlet--> <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:ApplicationContext.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> <!-- 乱码过滤--> <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> <!-- Session--> <session-config> <session-timeout>15</session-timeout> </session-config> </web-app>
相关文章推荐
- SSM配置文件完整版
- ssm(Spring+Spring mvc+mybatis)Dao层配置sql的文件——DeptDaoMapper.xml
- Spring Mvc+Spring+Mybatis(SSM)基础配置文件
- 【SSM框架】SSM整合的配置文件
- 搭建ssm框架项目基本原理和主要的配置文件小结
- ssm-xml配置文件基本信息
- SSM整合配置文件(Springmvc+Spring+Mybatis)
- 关于SSM的配置文件和Web.xml的配置
- 实习日三-MAVEN配置和SSM基本文件
- SSM 集成的两个配置文件
- SSM(使用配置文件)
- SSM配置文件
- ssm整合的配置文件
- SSM的基本集成配置文件
- SSM整合配置文件(Springmvc+Spring+Mybatis)
- SSM综合配置文件【注解】
- SSM框架实现增删查改包括jar包以及配置文件
- ssm框架整合的配置文件applicationContext.xml
- SSM:spring+springmvc+mybatis框架中的XML配置文件功能
- SSM整合(二):配置文件编写