mybatis返回map類型數據空值字段不顯示

注:返回完整的屬性集合,避免前端出現undifind。

與此方式配合使用配置:https://blog.csdn.net/qq_38493490/article/details/80421280

1、springMVC和boot通用配置:

<?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>


2、boot專用配置:

在application.properties中添加:

mybatis.configuration.call-setters-on-nulls=true


3、每個sql返回字段做判斷(通用boot、mvc、比較麻煩):

    IFNULL(name,'') as name

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章