The problem encountered in the development of SSM interface: when the value is empty, the key is not returned, resulting in a null pointer on the client side

The problem encountered in the development of SSM interface: when the value is empty, the key is not returned, resulting in a null pointer on the client side

Description of the problem: When the interface is developed, when the field value in the database is empty, even the key name is not returned (MyBatis principle problem), resulting in inconsistent returned data sets
The callSettersOnNulls property of MyBatis can be set to true

solve:

Add the following configuration to SQLFactory in the configuration file:

  <property name="configurationProperties">
       <props>
            <prop key="cacheEnabled">true</prop>
            <prop key="callSettersOnNulls">true</prop>
       </props>
  </property>

Return null when the set value is empty, effectively solving the problem of client null pointers

Guess you like

Origin blog.csdn.net/qq_44444470/article/details/116355742