spring mvc将空字串转换成null配置

在applicationContext配置文件中添加

1
2
3
4
5
6
7
8
9
10
11
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.lang.String">
<bean class="org.springframework.beans.propertyeditors.StringTrimmerEditor">
<constructor-arg name="emptyAsNull" value="true"/>
</bean>
</entry>
</map>
</property>
</bean>

您的支持将鼓励我继续创作!