1、spring主配置文件

<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!--第一步,扫描service-->
<context:component-scan base-package="com.zmh.ssm.service.impl"></context:component-scan>
<!--第二步,加载jdbc.properties-->
<context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
<!--第三步,创建dbcp数据源连接池-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${driver}"></property>
<property name="url" value="${url}"></property>
<property name="username" value="${user}"></property>
<property name="password" value="${password}"></property>
</bean>
<!--第四步,创建mybatis的工厂类对象-->
<bean class="org.mybatis.spring.SqlSessionFactoryBean">
<!--指定数据源-->
<property name="dataSource" ref="dataSource"></property>
<!--加载mybatis的映射文件 在value中可以使用*号通配符-->
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean>
<!--第五步,在spring的工厂中生成dao接口的实现类对象-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--指定要扫描哪个包下面所有的dao接口-->
<property name="basePackage" value="com.zmh.ssm.dao"></property>
</bean>
<!--第六步,创建spring的事物管理器-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!--第七步,声明以注解的方式配置声明式事物-->
<tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>
</beans>

2、spring-mvc主配置文件

 <?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 http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--扫描控制器包-->
<context:component-scan base-package="com.zmh.ssm.controller"></context:component-scan>
<!--声明以注解的方式配置spring mvc 相当于配置类
RequestMappingHandlerMapping 处理器映射器
RequestMappingHandlerAdapter 处理器适配器
-->
<mvc:annotation-driven></mvc:annotation-driven>
<!--配置spring mvc默认的jsp视图解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!--配置返回视图的前缀-->
<property name="prefix" value="/WEB-INF/jsp/"></property>
<!--配置返回视图的后缀-->
<property name="suffix" value=".jsp"></property>
</bean>
</beans>

3、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">
<!--配置spring的核心控制器-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--手动指定spring的主配置文件的位置和名称-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value>
</context-param>
<!--配置spring mvc的前端控制器-->
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--指定spring mvc的主配置文件的位置和名称-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
</servlet> <servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!--配置编码过滤器,解决post请求中文乱码问题-->
<filter>
<filter-name>characterEncodingFilter</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>
<init-param>
<param-name>forceResponseEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

ssm框架 spring的主配置文件 spring-mvc主配置文件 web.xml配置文件(基础的配置文件)的更多相关文章

  1. SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)【申明:来源于网络】

    SSM框架--详细整合教程(Spring+SpringMVC+MyBatis)[申明:来源于网络] 地址:http://blog.csdn.net/u014662268/article/details ...

  2. [转]SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)

    原文地址:http://blog.csdn.net/zhshulin/article/details/37956105#comments 使用SSM(Spring.SpringMVC和Mybatis) ...

  3. SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)

    1.前言 使用框架都是较新的版本: Spring 4.0.2 RELEASE Spring MVC 4.0.2 RELEASE MyBatis 3.2.6 2.Maven引入需要的JAR包 2.1设置 ...

  4. SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)【转载】

    最近在学习Spring+SpringMVC+MyBatis的整合.以下是参考网上的资料自己实践操作的详细步骤. 1.基本概念   1.1.Spring Spring是一个开源框架,Spring是于20 ...

  5. 【转】SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)

    原文地址:http://blog.csdn.net/zhshulin/article/details/37956105 使用SSM(Spring.SpringMVC和Mybatis)已经有三个多月了, ...

  6. Maven整合SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)

    使用SSM(Spring.SpringMVC和Mybatis)已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没有记录SSM整合 ...

  7. 转:SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)

    转:https://www.cnblogs.com/zyw-205520/p/4771253.html 1.基本概念   1.1.Spring Spring是一个开源框架,Spring是于2003 年 ...

  8. SSM框架——具体整合教程(Spring+SpringMVC+MyBatis)

    使用SSM(Spring.SpringMVC和Mybatis)已经有三个多月了.项目在技术上已经没有什么难点了,基于现有的技术就能够实现想要的功能.当然肯定有非常多能够改进的地方.之前没有记录SSM整 ...

  9. 《SSM框架搭建》三.整合spring web

    感谢学习http://blog.csdn.net/zhshulin/article/details/37956105#,还是修改了spring到最新的版本和接口开发示例 根据前一篇日志,已经有了myb ...

  10. 如何用Java类配置Spring MVC(不通过web.xml和XML方式)

    DispatcherServlet是Spring MVC的核心,按照传统方式, 需要把它配置到web.xml中. 我个人比较不喜欢XML配置方式, XML看起来太累, 冗长繁琐. 还好借助于Servl ...

随机推荐

  1. OpenCV中图像的读取,显示与保存

      图像的读取,显示与保存 相关函数:cv2.imread().cv2.imshow().cv2.imwrite() 1.读入图像: 用cv2.imread()函数来读取图像,cv2.imread(路 ...

  2. CodeForce:732B-Cormen — The Best Friend Of a Man

    传送门:http://codeforces.com/problemset/problem/732/B Cormen - The Best Friend Of a Man time limit per ...

  3. HTML中块级元素和行内元素的总结和区分。

    HTML标签 html标签定义: 是由一对尖括号包裹的单词构成,例如: <html>. 标签不区分大小写<html> 和 <HTML>, 推荐使用小写. 标签分为两 ...

  4. 自己做一款简易的chrome扩展--清除页面广告

    大家肯定有这样的经历,浏览网页的时候,左右两端广告,诸如“屠龙宝刀,点击就送”,以及最近火的不行的林子聪37传奇霸业什么“霸业面具,霸业吊坠”的魔性广告总是充斥我们的眼球. 当然有现成的扩展程序或者插 ...

  5. day05_01 鸡汤+内容回顾

    推荐电影: 1.被解救的姜戈 2.华尔街之狼 3.阿甘正传 4.辛德勒的名单 5.肖申克的救赎 6.上帝之城 7.焦土之城 8.绝美之城 打印多行 msg = "hello 1 hello ...

  6. 06-python进阶-多线程下载器练手

    我们需要用python 写一个多线程的下载器 我们要先获取这个文件的大小 然后将其分片 然后启动多线程 分别去下载 然后将其拼接起来 #!/usr/bin/env python#coding:utf- ...

  7. oracle 可以连接数据库,vs连不上. 报错提示:ORA-12154: TNS: 无法解析指定的连接标识符

    方法1:问题:VS 连接 Data Source=ORCL_Service19;User Id=*;Password=* 连接不上 oracle 可以连接数据库,vs连不上,报错提示:ORA-1215 ...

  8. MySQL将内存用在了哪里

    本片文章参考官网讲述MySQL是如何分配内部内存,同时涉及到如何合适设的置内存分配以及如何监控内存的使用情况 官方文档 MySQL在启动时默认被分配给512MB RAM,可以通过设置相关内存参数对其进 ...

  9. wireshark推荐书籍

    1 wireshark数据包分析实战 有中文版 2 wireshark网络分析 英文版 3 TCP/IP协议栈详解卷一

  10. Unity 过度光照贴图

    背景:开关窗帘过程,让环境在亮和暗之间过度 事先烘培出亮.暗两张Lighting map.然后代码实现,窗帘开关由动作实现,而代码中通过动作执行进度来过度两张Lighting map void OnA ...