SSM整合配置文件
来源:互联网 发布:网络直播电视 编辑:程序博客网 时间:2024/05/21 10:07
web.xml
?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<filter-name>encoding</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>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>mvc</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>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- 监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
</web-app>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<!--扫描注释 -->
<context:component-scan base-package="com.xxx">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- c3p0连接池 -->
<bean id="dbcp" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 用户名 -->
<property name="user" value="root" />
<!-- 用户密码 -->
<property name="password" value="root" />
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/student?characterEncoding=utf-8" />
</bean>
<!-- sqlSessionFactory的注入 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dbcp"></property>
<!--mybatis映射文件 -->
<property name="mapperLocations">
<list>
<value>classpath:com/xxx/dao/*Mapper.xml</value>
</list>
</property>
<property name="typeAliasesPackage" value="com.xxx.pojo"></property>
</bean>
<!--包扫描 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.xxx.dao"></property>
</bean>
<!--事务管理 -->
<bean id="tx"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dbcp"></property>
</bean>
<!--声明式事务 -->
<tx:annotation-driven transaction-manager="tx" />
</beans>
springmvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-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/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<!-- 包扫描 -->
<context:component-scan base-package="com.xxx.controller"></context:component-scan>
<!-- 视图解析器 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- date格式转换 -->
<bean id="dateConverter" class="com.xxx.dateconverter.DateConverter"></bean>
<bean id="dc"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="converters" ref="dateConverter">
</property>
</bean>
<!--验证码 -->
<bean id="captcha" class="com.google.code.kaptcha.servlet.KaptchaExtend">
<constructor-arg>
<props>
<prop key="kaptcha.border">no</prop>
<!-- 这个key值是在session作用域中的 -->
<prop key="kaptcha.session.key">code</prop>
<!-- 验证码的长度 -->
<prop key="kaptcha.textproducer.char.length">4</prop>
<!-- 背景颜色 -->
<prop key="kaptcha.background.clear.from">211,229,237</prop>
<prop key="kaptcha.background.clear.to">211,239,235</prop>
</props>
</constructor-arg>
</bean>
<!--拦截器拦截强制登陆 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/user/update.do" />
<mvc:mapping path="/user/selectStudents.do" />
<bean class="com.xxx.interceptor.MyInterceptor"></bean>
</mvc:interceptor>
</mvc:interceptors>
<!-- AJAX中json校验 -->
<mvc:annotation-driven conversion-service="dc">
<mvc:message-converters register-defaults="false">
<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
<bean id="fastJsonHttpMessageConverter"
class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<!-- 这里顺序不能反,一定先写text/html,不然ie下出现下载提示 -->
<!-- <value>text/html;charset=UTF-8</value> -->
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
</beans>
- SSM整合之配置文件
- ssm整合的配置文件
- SSM整合配置文件
- SSM整合配置文件
- ssm整合的配置文件
- SSM项目配置文件整合
- maven+ssm整合配置文件
- SSM框架整合 配置文件
- SSM 整合核心配置文件
- 整合ssm框架之配置文件
- SSM项目的配置文件整合
- SSM整合的配置文件详解
- SSM框架整合配置文件整理
- SSM整合配置文件(Springmvc+Spring+Mybatis)
- SSM(spring+mybatis+springmvc)整合 配置文件
- SSM整合配置文件(Springmvc+Spring+Mybatis)
- SSM整合配置文件(Springmvc+Spring+Mybatis)
- SSM整合配置文件(Springmvc+Spring+Mybatis)
- Java集合基础篇(3)-HashSet基本用法
- SVM算法(二)(有监督学习)
- @RequestMapping Annotation with Controller, Methods, Headers, Params, @RequestParam, @PathVariable
- 如何解决空虚感?
- 理解GloVe模型(Global vectors for word representation)
- SSM整合配置文件
- Python3学习笔记
- win7 java开发环境安装
- 高通平台中gpio简单操作和调试
- Tomcat源码分析(一)------ 架构
- 查看电脑主板支持多大内存
- POJ 3304 Segments (直线和线段相交判断)
- PHP数组按照指定字段排序
- 基因组信息学小笔记