解决mybatis空字段null字段不返回

创建configuration.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD SQL MAP Config 3.1//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <settings> <setting name="callSettersOnNulls" value="true"/> </settings> </configuration> 

配置Mybatis的SqlSessionFactoryBean

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:/META-INF/spring/configuration.xml" /> <property name="mapperLocations" value="classpath:/META-INF/spring/mybatis/modelMap/*.xml" /> </bean>

 在这种配置中,age将以null值映射到map中。

posted @ 2019-03-14 17:19  听风的dog  阅读(6284)  评论(0编辑  收藏  举报