# SSM **Repository Path**: AidenX/ssm ## Basic Information - **Project Name**: SSM - **Description**: 简单的SSM整合 - **Primary Language**: Unknown - **License**: MulanPSL-1.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-27 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SSM #### 介绍 简单的SSM整合 #### 项目配置要点: 文件webapp/WEB-INF/web.xml引用了Spring MVC配置文件;Spring MVC配置文件加载了整合文件。 #### SSM整合时,需要注意版本的匹配(如Mybatis 3.30、Spring MVC 4.1.7及mybatis-spring-1.2.3.jar匹配)。 与基于映射文件的方式相比,在Spring整合Mybatis的配置文件中,不必指定来指定映射文件位置。 映射接口文件需要对接口方法进行注解(无SQL id)。例如: @Select("select * from user where username=#{un}") /* 根据用户名查找 */ //public User getUserByUsername(String un); //仅仅一个参数时 public User getUserByUsername(@Param("un")String un); //标准些,便于扩展 @Select("select * from user where username=#{un} and password=#{pwd}") /* 根据用户名和密码2个参数查找时,参数必须在接口方法定义里注解 */ public User getUserByUsernameAndPassword(@Param("un")String un,@Param("pwd")String pwd); 本方式比写“DAO接口+XML映射文件”方式简便一些。 获取项目根路径的两种方法: <%=request.getContextPath() %> 或者: ${pageContext.request.contextPath}