SSM三框架整合配置文件

it2026-01-10  6

SSM 三框架整合配置文件

摘自 ssm框架详细整合教程

基本概念:

Spring:

Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,由Rod Johnson 在其著作Expert One-On-One J2EE Development and Design中阐述的部分理念和原型衍生而来。它是为了解决企业应用开发的复杂性而创建的。Spring使用基本的JavaBean来完成以前只可能由EJB完成的事情。然而,Spring的用途不仅限于服务器端的开发。从简单性、可测试性和松耦合的角度而言,任何Java应用都可以从Spring中受益。 简单来说,Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架。

Spring MVC:

Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面。Spring MVC 分离了控制器、模型对象、分派器以及处理程序对象的角色,这种分离让它们更容易进行定制。

MyBatis:

MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBatis 。MyBatis是一个基于Java的持久层框架。iBATIS提供的持久层框架包括SQL Maps和Data Access Objects(DAO)MyBatis 消除了几乎所有的JDBC代码和参数的手工设置以及结果集的检索。MyBatis 使用简单的 XML或注解用于配置和原始映射,将接口和 Java 的POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。

配置文件部分:

pom文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.javen.maven01</groupId> <artifactId>maven01</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>maven01 Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <!-- spring版本号 --> <spring.version>4.0.2.RELEASE</spring.version> <!-- mybatis版本号 --> <mybatis.version>3.2.6</mybatis.version> <!-- log4j日志文件管理包版本 --> <slf4j.version>1.7.7</slf4j.version> <log4j.version>1.2.17</log4j.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <!-- 表示开发的时候引入,发布的时候不会加载此包 --> <scope>test</scope> </dependency> <!-- <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> --> <!-- spring核心包 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> </dependency> <!-- mybatis核心包 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <!-- mybatis/spring包 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.2</version> </dependency> <!-- 导入java ee jar 包 --> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>7.0</version> </dependency> <!-- 导入Mysql数据库链接jar包 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.36</version> </dependency> <!-- 导入dbcp的jar包,用来在applicationContext.xml中配置数据库 --> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.2.2</version> </dependency> <!-- JSTL标签类 --> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!-- 日志文件管理包 --> <!-- log start --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <!-- 格式化对象,方便输出日志 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.1.41</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <!-- log end --> <!-- 映入JSON --> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.13</version> </dependency> <!-- 上传组件包 --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.9</version> </dependency> </dependencies> <build> <finalName>maven01</finalName> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.2.8.v20150217</version> <configuration> <httpConnector> <port>80</port> </httpConnector> <stopKey>shutdown</stopKey> <stopPort>9966</stopPort> </configuration> </plugin> </plugins> </build> </project>

如果java版本在8以上,建议用mybatis 3.5.3 版本,否则会出现 WARNING: An illegal reflective access operation has occurred 错误。

配置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:p="http://www.springframework.org/schema/p" 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-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 --> <context:component-scan base-package="com.javen.controller" /> <!-- 扩充了注解驱动,可以将请求参数绑定到控制器参数 --> <mvc:annotation-driven/> <!-- 静态资源处理 css js imgs --> <mvc:resources location="/resources/**" mapping="/resources"/> <!--避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON转换器 --> </list> </property> </bean> <!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- 默认编码 --> <property name="defaultEncoding" value="utf-8" /> <!-- 文件大小最大值 --> <property name="maxUploadSize" value="10485760000" /> <!-- 内存中的最大值 --> <property name="maxInMemorySize" value="40960" /> <!-- 启用是为了推迟文件解析,以便捕获文件大小异常 --> <property name="resolveLazily" value="true"/> </bean> <!-- 配置ViewResolver 。可用多个ViewResolver 。使用order属性排序。 InternalResourceViewResolver 放在最后--> <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="order" value="1"></property> <property name="mediaTypes"> <map> <!-- 告诉视图解析器,返回的类型为json格式 --> <entry key="json" value="application/json" /> <entry key="xml" value="application/xml" /> <entry key="htm" value="text/htm" /> </map> </property> <property name="defaultViews"> <list> <!-- ModelAndView里的数据变成JSON --> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /> </list> </property> <property name="ignoreAcceptHeader" value="true"></property> </bean> <!-- 定义跳转的文件的前后缀 ,视图模式配置--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 --> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </beans>

配置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" version="3.0"> <display-name>Archetype Created Web Application</display-name> <!-- Spring和mybatis的配置文件 --> <!-- <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mybatis.xml</param-value> </context-param> --> <!-- 编码过滤器 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <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> <!-- Spring监听器 --> <!-- <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> --> <!-- 防止Spring内存溢出监听器 --> <!-- <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> --> <!-- Spring MVC servlet --> <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:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <!-- 此处可以可以配置成*.do,对应struts的后缀习惯 --> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list> </web-app>

log4j.properties:(Log4j的配置)

log4j.rootLogger=INFO,Console,File #定义日志输出目的地为控制台 log4j.appender.Console=org.apache.log4j.ConsoleAppender log4j.appender.Console.Target=System.out #可以灵活地指定日志输出格式,下面一行是指定具体的格式 log4j.appender.Console.layout = org.apache.log4j.PatternLayout log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n #文件大小到达指定尺寸的时候产生一个新的文件 log4j.appender.File = org.apache.log4j.RollingFileAppender #指定输出目录 log4j.appender.File.File = logs/ssm.log #定义文件最大大小 log4j.appender.File.MaxFileSize = 10MB # 输出所以日志,如果换成DEBUG表示输出DEBUG以上级别日志 log4j.appender.File.Threshold = ALL log4j.appender.File.layout = org.apache.log4j.PatternLayout log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n

jdbc.properties:(文件编码修改为utf-8,建立JDBC属性文件)

driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/maven username=root password=root #定义初始连接数 initialSize=0 #定义最大连接数 maxActive=20 #定义最大空闲 maxIdle=20 #定义最小空闲 minIdle=1 #定义最长等待时间 maxWait=60000

spring-mybatis.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:p="http://www.springframework.org/schema/p" 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-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <!-- 自动扫描 --> <context:component-scan base-package="com.javen" /> <!-- 引入配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:jdbc.properties" /> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${driver}" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> <!-- 初始化连接大小 --> <property name="initialSize" value="${initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${maxIdle}"></property> <!-- 连接池最小空闲 --> <property name="minIdle" value="${minIdle}"></property> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="${maxWait}"></property> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:com/javen/mapping/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.javen.dao" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> </beans>

xxxMapper.xml:

这里的mybatis是后加上的只为加固复习

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.dao.UserMapper"> <!-- <select id="count" resultType="int"> select count(1) as count from smbms_user; </select>--> <!--查寻所有--> <select id="getUserList" resultType="com.pojo.User"> select * from smbms_user; </select> <!--根据名字模糊查询--> <select id="getUserListByUserName" parameterType="String" resultType="com.pojo.User"> select * from smbms_user where userName like concat('%',#{userName},'%') </select> <!--模糊查询加条件查询--> <select id="getUserListByUser" parameterType="com.pojo.User" resultType="com.pojo.User"> select * from smbms_user where userName like concat('%',#{userName},'%') and userRole=#{userRole} </select> <select id="getUserListByUser1" parameterType="com.pojo.User" resultType="com.pojo.User"> select * from smbms_user where userName like concat('%',#{uName},'%') and userRole=#{uRole} </select> <!--查询中 resultMap的使用--> <resultMap id="userList" type="com.pojo.User"> <id property="id" column="id"/> <result property="userCode" column="userCode"/> <result property="userName" column="userName"/> <result property="phone" column="phone"/> <result property="birthday" column="birthday"/> <result property="gender" column="gender"/> <result property="userRole" column="userRole"/> <!--<result property="userRoleName" column="roleName"/>--> </resultMap> <select id="getUserList2" parameterType="com.pojo.User" resultMap="userList"> select u.*,r.roleName from smbms_user u,smbms_role r where u.userName like concat('%',#{userName},'%') and u.userRole=#{userRole} and u.userRole=r.id </select> <!--添加语句--> <insert id="addUser" parameterType="com.pojo.User"> insert into smbms_user (userCode,userName,userPassword,gender,birthday,phone,address,userRole,createdBy,creationDate) values (#{userCode},#{userName},#{userPassword},#{gender},#{birthday},#{phone},#{address},#{userRole},#{createdBy},#{creationDate}) </insert> <!--修改语句--> <update id="updateUser" parameterType="com.pojo.User"> update smbms_user set userCode=#{userCode},userName=#{userName},userPassword=#{userPassword},gender=#{gender},birthday=#{birthday},phone=#{phone},address=#{address},userRole=#{userRole},modifyBy=#{modifyBy},modifyDate=#{modifyDate} where id=#{id} </update> <update id="updatePwd" parameterType="com.pojo.User"> update smbms_user set userPassword=#{userPassword} where id=#{id} </update> <!--删除语句--> <delete id="deleteUser" parameterType="int"> delete from smbms_user where id=#{id} </delete> <!--多表联合查询--> <resultMap id="userRoleResult" type="com.pojo.User"> <id property="id" column="id"/> <result property="userCode" column="userCode"/> <result property="userName" column="userName"/> <result property="userRole" column="userRole"/> <association property="role" javaType="com.pojo.Role" resultMap="roleResult"/> </resultMap> <!--通过 association标签将 resultMap(另一个表)属性抽出--> <resultMap id="roleResult" type="com.pojo.Role"> <id property="id" column="r_id"/> <result property="roleCode" column="roleCode"/> <result property="roleName" column="roleName"/> </resultMap> <select id="getUserList3" parameterType="com.pojo.User" resultMap="userRoleResult"> select u.*,r.id as r_id,r.roleCode,r.roleName from smbms_user u,smbms_role r where u.userRole=#{userRole} and u.userRole=r.id </select> <!--多表联合查询--> <resultMap id="userAddressResult" type="com.pojo.User"> <id property="id" column="id"/> <result property="userCode" column="userCode"/> <result property="userName" column="userName"/> <collection property="addressList" ofType="com.pojo.Address" resultMap="addressResult"> <!--<id property="id" column="a_id"/> <result property="contact" column="contact"/> <result property="addressDesc" column="addressDesc"/> <result property="tel" column="tel"/> <result property="postCode" column="postCode"/>--> </collection> </resultMap> <resultMap id="addressResult" type="com.pojo.Address"> <id property="id" column="a_id"/> <result property="contact" column="contact"/> <result property="addressDesc" column="addressDesc"/> <result property="postCode" column="postCode"/> <result property="tel" column="tel"/> </resultMap> <select id="getUserById" parameterType="Integer" resultMap="userAddressResult"> select u.*,a.id as a_id,a.contact,a.addressDesc,a.postCode,a.tel from smbms_user u,smbms_address a where u.id=a.userId and u.id=#{id} </select> <!--动态SQL —— if标签--> <select id="getUserListByUser3" resultMap="userList"> select u.*,r.roleName as userRoleName from smbms_user u,smbms_role r where u.userRole=r.id <if test="userRole!=null">and u.userRole=#{userRole}</if> <if test="userName!=null and userName!=''">and u.userName like concat ('%',#{userName},'%')</if> </select> <!--动态SQL —— trim-if标签--> <select id="getUserList4" resultMap="userList"> select * from smbms_user <trim prefix="where" prefixOverrides="and/or"> <if test="userName!=null and userName!=''">u.userName like concat ('%',#{userName},'%')</if> <if test="userRole!=null">and userRole=#{userRole}</if> </trim> <!--<where> <if test="userName!=null and userName!=''">u.userName like concat ('%',#{userName},'%')</if> <if test="userRole!=null"> and userRole=#{userRole}</if> </where>--> </select> <!--动态SQL —— foreach标签(用list集合传值)--> <select id="getUserRole_foreach1" resultType="com.pojo.User" resultMap="userList"> select * from smbms_user where userRole in <foreach collection="list" item="roleList" open="(" separator="," close=")"> #{roleList} </foreach> </select> <!--动态SQL —— foreach标签(用array数组传值)--> <select id="getUserRole_foreach2" resultType="com.pojo.User" resultMap="userList"> select * from smbms_user where userRole in <foreach collection="array" item="roleId" open="(" separator="," close=")"> #{roleId} </foreach> </select> <!--动态SQL —— foreach标签(用map集合传值)--> <!--注意,这个项目中实现将数据放入list集合,再对应的存入map集合,所以注意collection与item变化--> <select id="getUserRole_foreach3" resultType="com.pojo.User" resultMap="userList"> select * from smbms_user where gender=#{gender} and userRole in <foreach collection="roleMap" item="roleId" open="(" separator="," close=")"> #{roleMap} </foreach> </select> <!--动态SQL —— choose标签(这里的 where 1=1 必须——意思是如果没有限定条件就查询所有)--> <select id="getUserList5" resultType="com.pojo.User"> select * from smbms_user where 1=1 <choose> <when test="userName!=null and userName!=''">and u.userName like concat ('%',#{userName},'%')</when> <when test="userRole!=null">and userRole=#{userRole}</when> <when test="userCode!=null">and userCode=#{userCode}</when> <when test="creationDate!=null">and creationDate=#{creationDate}</when> <otherwise> and year(creationDate)=year(#{creationDate}) </otherwise> </choose> </select> <!--动态SQL —— set/trim-if标签(做修改用)--> <update id="modifyUser" parameterType="com.pojo.User"> update smbms_user set <!--<set> <if test="userCode!=null">userCode=#{userCode}</if> <if test="userName!=null">userName=#{userName}</if> <if test="userPassword!=null">userPassword=#{userPassword}</if> <if test="gender!=null">gender=#{gender}</if> <if test="birthday!=null">birthday=#{birthday}</if> <if test="phone!=null">phone=#{phone}</if> <if test="address!=null">address=#{address}</if> <if test="userRole!=null">userRole=#{userRole}</if> <if test="modifyBy!=null">modifyBy=#{modifyBy}</if> <if test="modifyDate!=null">modifyDate=#{modifyDate}</if> </set> where id=#{id}--> <trim prefix="set" prefixOverrides="and/or" suffix="where id=#{id}"> <if test="userCode!=null">userCode=#{userCode}</if> <if test="userName!=null">userName=#{userName}</if> <if test="userPassword!=null">userPassword=#{userPassword}</if> <if test="gender!=null">gender=#{gender}</if> <if test="birthday!=null">birthday=#{birthday}</if> <if test="phone!=null">phone=#{phone}</if> <if test="address!=null">address=#{address}</if> <if test="userRole!=null">userRole=#{userRole}</if> <if test="modifyBy!=null">modifyBy=#{modifyBy}</if> <if test="modifyDate!=null">modifyDate=#{modifyDate}</if> </trim> </update> </mapper>

如果弄不清association 与 collection标签的区别请参考—>Mybatis中collection和association的使用区别

最新回复(0)