环境信息

JDK1.7 + Tomcat7 + spring4.0

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"><welcome-file-list><welcome-file>index.html</welcome-file></welcome-file-list><!-- post请求编码设置 --><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><!--监听器: 监听项目启动,加载配置文件--><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- spring 扫描--><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:conf/spring-application.xml</param-value></context-param><!-- spring mvc --><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:conf/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>
</web-app>

spring-application.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:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-4.1.xsd"><context:property-placeholder location="classpath:conf/application.properties"/><!-- 数据源配置 --><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><property name="driverClassName" value="{jdbc.driver}"/><property name="url" value="{jdbc.url}"/><property name="username" value="{jdbc.username}"/><property name="password" value="{jdbc.password}"/></bean><!-- 数据工厂配置 --><bean id="sqlFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource"/><property name="configLocation" value="classpath:conf/mybatis-config.xml"/><property name="typeAliasesPackage" value="com.huawei.demo.entity"/><!-- 扫描mapper.xml文件 --><property name="mapperLocations"><list><value>classpath:mapper/*.xml</value></list></property></bean><!-- 扫描da层接口--><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.huawei.demo.mapper"/><property name="sqlSessionFactoryBeanName" value="sqlFactory"/></bean><!-- 扫描出控制层之外的service层 --><context:component-scan base-package="com.huawei.demo"><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan><bean id="txManage" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"/></bean><!-- 启用事务注解驱动,自动扫描注册 --><tx:annotation-driven transaction-manager="txManage"/><import resource="classpath:conf/spring-mvc.xml"/></beans>

spring-mvc.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.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"><!-- 只扫描控制层 --><context:component-scan base-package="com.huawei.demo"><context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan><!-- 静态资源处理 --><mvc:default-servlet-handler/><!-- 视图解析 --><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/page/"/><property name="suffix" value=".html"/></bean><!-- 静态资源加载 --><mvc:resources location="/static/" mapping="/static/**"/><!-- 拦截器 --><mvc:interceptors><mvc:interceptor><mvc:mapping path="/**" /><bean class="com.huawei.demo.interceptor.LoginInterceptor"/></mvc:interceptor></mvc:interceptors><mvc:annotation-driven /></beans>

mybatis-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD SQL Map Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><settings><!-- 使用数据库自增主键 --><setting name="useGeneratedKeys" value="true"/><!-- 使用列别名--><setting name="useColumnLabel" value="true"/><!-- 启用驼峰命名转换--><setting name="mapUnderscoreToCamelCase" value="true"/></settings>
</configuration>

项目结构

依赖jar包

ssm 框架配置详解相关推荐

  1. java ssm框架_JavaWeb开发SSM框架搭建详解

    1.需要用到的jar包:由于很多的jar包不好下载,我直接上传到百度网盘: 很多,而且不好下载,我已经整理好好了: 关于SSM框架:以前的博客有介绍过 第一步:创建Dynamic Web Projec ...

  2. SSM框架-SpringMVC详解,kafka常见的面试问题

    前言 Redis是企业级系统高并发.高可用架构中非常重要的一个环节.Redis主要解决了关系型数据库并发量低的问题,有助于缓解关系型数据库在高并发场景下的压力,提高系统的吞吐量(具体Redis是如何提 ...

  3. SpringMVC 框架系列之组件概述与配置详解

    在上一篇文章 SpringMVC 框架系列之初识与入门实例 的实例中,我们已经知道,SpringMVC 框架是一个 web 层的框架,本篇文章就详细解释一下 SpringMVC 框架具体文件的配置以及 ...

  4. SpringSecurity权限管理框架系列(六)-Spring Security框架自定义配置类详解(二)之authorizeRequests配置详解

    1.预置演示环境 这个演示环境继续沿用 SpringSecurit权限管理框架系列(五)-Spring Security框架自定义配置类详解(一)之formLogin配置详解的环境. 2.自定义配置类 ...

  5. Spring框架深入(四)--SpringMVC配置详解

    一.SpringMVC web模型 二.@RequestMapping参数说明 1.value:定义处理方法的请求的URL地址: 2.method:定义处理的方法的http method类型,如GET ...

  6. java log4j基本配置及日志级别配置详解,java基础面试笔试题

    我总结出了很多互联网公司的面试题及答案,并整理成了文档,以及各种学习的进阶学习资料,免费分享给大家. 扫描二维码或搜索下图红色VX号,加VX好友,拉你进[程序员面试学习交流群]免费领取.也欢迎各位一起 ...

  7. mybatis 同名方法_MyBatis(四):xml配置详解

    目录 1.我们将 数据库的配置语句写在 db.properties 文件中 2.在 mybatis-configuration.xml 中加载db.properties文件并读取 通过源码我们可以分析 ...

  8. 微信小程序02【配置详解、生命周期-app对象使用、页面跳转详解】

    学习地址:https://www.bilibili.com/video/BV1sx411z77P 笔记01:https://blog.csdn.net/weixin_44949135/article/ ...

  9. java定时任务框架elasticjob详解

    这篇文章主要介绍了java定时任务框架elasticjob详解,Elastic-Job是ddframe中dd-job的作业模块中分离出来的分布式弹性作业框架.该项目基于成熟的开源产品Quartz和Zo ...

最新文章

  1. robot framework中的timeout的关键词
  2. 连接maven_如何在Eclipse中使用Maven工程连接远程的Spark
  3. 如何知道linux的ssh秘钥是否匹配,SSH密钥验证
  4. Linux操作基础(十七)之Systemd入门教程(二)实战篇
  5. Delphi的TdxDBGrid自带的一些有用的导出文件的函数(EXCEL、HTML、XML、TXT、INI、Registry等)
  6. python提取xml的所有框坐标_python 提取批量xml文件中的坐标信息存入txt文件 xml文件转txt文件...
  7. 印象笔记 离线版_印象笔记pc版离线
  8. 安卓android视频录制、另一部手机实时观看方案
  9. 2019 中文互联网资源碎碎念
  10. 网络与社会导论之幂律与富者更富及其与长尾、齐普夫定律等的关系
  11. JavaSE----基础语法(数组)
  12. Java输入时间输出热量卡路里的小程序
  13. 论文学习笔记:PoseFix: Model-agnostic General Human Pose Refinement Network
  14. 面试题:在9个点上画十条直线,每条直线上至少三个点
  15. Python实现旋转按钮控制小风扇
  16. word中使用宏批量插入图片
  17. Win10电脑如何格式化
  18. hibernate - mappedby的理解
  19. 实验四 MIPS寄存器文件设计 Logisim
  20. 山大华特卧龙学校第一届ACM赛后总结_题目

热门文章

  1. 现有CSDN博客的排名机制
  2. 在线音乐用户寄望用爱发电,资本不愿无米之炊
  3. Naveen Tewari先生荣获艾奇奖“年度商业创新领袖人物”
  4. oracle 创建表空间 pcincrease,oracle建表空间 各种语句
  5. java中为什么要用json_Java中使用JSON
  6. python 读grid 数据_科学网—Python_机器学习_总结14:Grid search - 李军的博文
  7. python导入标准库对象的语句_Python项目中如何优雅的import
  8. 扩展虚拟机Ubuntu磁盘容量空间
  9. python中几种推导式的特殊用法
  10. 一文搞懂 Python 的 import 机制