ssm回顾笔记(一)
这两天来到了农银,这边即将进行的一个项目是将ssh框架的电商项目迁移到springboot+ssm框架上,所以我基本上是三门技术在同时进行学习,当然以前学过ssm,现在只是回顾.
spring 注解
@Component 下细化了@Controller,@Service,@Repository,分别注解表示层,业务逻辑层,持久化层 @Scope,默认是 singleton,可以配置为 prototype
@Autowired 默认根据类型装配,可以装配多个参数的 setter 方法
@Resource,是 Java 的,必须是 JDK6 及以上,默认根据名称装配,如果找不到会根据
类型装配
RequestMapping 可以加在类和方法上,指定接收请求的路径
类:作用相当于命名空间
方法:请求的具体资源的路径
ResponseBody 将数据放到响应体中
回顾以前不用 maven 搭建开发环境的步骤(必须熟悉)
resource目录下的配置文件

在 web.xml 文件中进行配置
> spring 监听器 该监听器在服务器启动阶段被创建,解析 spring 的配置文件,监听实现了 ServletContextListener 接口,在创建 ServletContext 对象创建和销毁的时候,监听对象中的方法会被执行
> *过滤器:CharacterEncodingFilter解决 post 请求中文乱码的问题
> spring 的前端控制器 DispatcherServlet主要用来拦截符合要求的外部请求,并把请求分发到不同的控制器去处理,根据控制器处理后的结果,生成相应的响应发送到客户端默认解析在 WEB-INF 目录下找[servlet-name]-servlet.xml 文件,但是我们一般通过参数指定配置文件,而且尽量让这个配置文件的形式和 spring 总体的配置文件形式相同,那么在服务器启动的时候,前端控制器实例也会被创建
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1"> <!-- 指定spring配置文件路径 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-*.xml</param-value>
</context-param>
<!-- 配置spring监听器,该监听器在服务器启动阶段会被实例化,解析spring的配置文件;该监听器实现了ServletContextListener,监听ServletContext
对象,在ServletContext对象创建或者销毁的时候,监听器中的方法会被执行 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- 解决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>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 配置springMVC中央调度器 -->
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 指定springMVC配置文件的路径,不是必须要指定的;默认情况下,会去WEB-INF/[servlet-name]-servlet.xml,
但是一般我们都手动指定springMVC配置文件的路径,而且springMVC文件的命名尽量和spring配置文件风格一致 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
<!-- 在服务器启动阶段实例化该servlet -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
spring-base.xml(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:aop="http://www.springframework.org/schema/aop"
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
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- 注册组件扫描器 -->
<context:component-scan base-package="com.bjpowernode.epay.service.impl"/> <!-- 引入外部的配置文件,读取数据库配置信息 -->
<context:property-placeholder location="classpath:jdbc.properties"/> <!-- 数据源 c3p0 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driver}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.user}"/>
<property name="password" value="${jdbc.password}"/>
</bean> <!-- sessionFactory -->
<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations">
<list>
<value>classpath:com/bjpowernode/epay/dao/*.xml</value>
</list>
</property>
</bean> <!-- 配置mapper扫描器 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.bjpowernode.epay.dao"/>
<property name="sqlSessionFactoryBeanName" value="sessionFactory"/>
</bean> <!-- TransactionManager -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean> <!-- 事务通知Advice Aspect是横切面,是一个抽象的概念,Advice是Aspect的具体实现 -->
<tx:advice id="transactionAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" isolation="DEFAULT" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
<tx:method name="get*" read-only="true"/>
</tx:attributes>
</tx:advice> <!-- AOP切入 -->
<aop:config>
<aop:advisor advice-ref="transactionAdvice" pointcut="execution(* com.bjpowernode.epay.service.*.*(..))"/>
</aop:config>
</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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
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/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!-- 注册组件扫描器 扫描所有处理器类 -->
<context:component-scan base-package="com.bjpowernode.epay.web.controller"/> <!-- 注册mvc注解驱动 -->
<mvc:annotation-driven/> <!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean> <!-- 注册拦截器 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/*/*.do"/>
<mvc:exclude-mapping path="/main/login.do"/>
<bean class="com.bjpowernode.epay.web.AuthInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
</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>
<settings>
<!-- 解决插入的时候有空值的情况 -->
<setting name="jdbcTypeForNull" value="NULL"/>
</settings>
<!-- 设置别名 -->
<typeAliases>
<package name="com.bjpowernode.epay.domain"/>
</typeAliases>
</configuration>
ssm回顾笔记(一)的更多相关文章
- iOS回顾笔记( 01 )
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...
- iOS回顾笔记( 02 ) -- 由九宫格布局引发的一系列“惨案”
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...
- iOS回顾笔记(03) -- 自定义View的封装和xib文件的使用详解
iOS回顾笔记(03) -- 自定义View的封装和xib文件的使用详解 iOS开发中,我们常常将一块View封装起来,以便于统一管理内部的子控件.如iOS回顾笔记(02)中的"书" ...
- iOS回顾笔记(04) -- UIScrollView的基本使用详解
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...
- iOS回顾笔记(05) -- 手把手教你封装一个广告轮播图框架
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...
- iOS回顾笔记(06) -- AutoLayout从入门到精通
iOS回顾笔记(06) -- AutoLayout从入门到精通 随着iOS设备屏幕尺寸的增多,当下无论是纯代码开发还是Xib/StoryBoard开发,自动布局已经是必备的开发技能了. 我使用自动布局 ...
- iOS回顾笔记(07) -- UITableView的使用和性能优化
iOS回顾笔记(07) -- UITableView的使用和性能优化 如果问iOS中最重要的最常用的UI控件是什么,我觉得UITableView当之无愧!似乎所有常规APP都使用到了UITableVi ...
- iOS回顾笔记(08) -- 自定义Cell的类型和创建步骤总结
iOS回顾笔记(08) -- 自定义Cell的类型和创建步骤总结 项目中我们常见的自定义cell主要分为两种 等高cell:如应用列表.功能列表 非等高cell:如微博列表.QQ聊天页面 下面对这 ...
- iOS回顾笔记(09) -- Cell的添加、删除、更新、批量操作
iOS回顾笔记(09) -- Cell的添加.删除.更新.批量操作 项目中经常有对UITableViewCell做各种操作的需求: 添加一个新的cell 删除某行cell 刷新cell上某行数据(如修 ...
随机推荐
- ArcGIS AddIn调用ArcMap自带的对话框
ESRI.ArcGIS.Framework命名空间提供了ArcGIS常用的一些对话框,可以在开发时直接调用这些对话框,而不需要重新去写Form 主要对话框有 1.IColorBrowser/IColo ...
- windows系统dos下查看无线网密码
(1)采用命令:netsh wlan show profiles 查看电脑连接过的无线网: (2)采用命令:netsh wlan show profile name ="wifi 名字&qu ...
- 减小ipa包大小
1.删除不用的文件和图片 2.打release模式 3.色调单一图片采用8-bit的,对32-bit的图片采用压缩 4.对音视频采用aac压缩
- Date Calendar
1 毫秒值概念 时间和日期的计算,必须依赖毫秒值获取当前日期的毫秒值:System.currentTimeMillis() 返回值long类型参数, 时间原点:公元1970年1月1日,午夜0:00:0 ...
- dyld_shared_cache_extract_dylibs failed
文章来源:https://www.jianshu.com/p/e276a784fbee s.png 数据线插上手机 Xcode->window 3.png 2.png 点击Unpai ...
- 编写自定义django-admin命令
Django为项目中每一个应用下的management/commands目录中名字没有以下划线开始的Python模块都注册了一个manage.py命令,我们可以利用这点来自定制一个命令(比如运行该命令 ...
- [svc]unix和cpu发展历史
最近搞汇编 , 有一款8086cpu,16bit, 支持内存1M 于是勾起了对计算机历史的兴趣,多了解了下 unix起源历史 [Unix发展历史 - 程序猿-贝岩博客 - CSDN博客]https:/ ...
- Docker:Windows7下使用docker toolbox(1)
一.安装 官方网址:https://docs.docker.com/docker-for-windows/install/ win10以下安装:https://www.docker.com/produ ...
- DX9 DirectX 索引缓存(IndexBuffer) 代码
// @time: 2012.3.22 // @author: jadeshu // des: 索引缓存 //包含头文件 #include <Windows.h> #include < ...
- tf.InteractiveSession()和tf.Session()
tf.InteractiveSession()适合用于python交互环境 tf.Session()适合用于源代码中 1.tf.InteractiveSession() 直接用eval()就可以直接获 ...