title: String Empty To Null - Empty Form Fields to null - Spring Editor - StringTrimmerEditor
body: <p>I have read few posts, and tried implementing the same way, but somehow i am getting below error. I want to implement through <code>XML based configuration</code>.</p>
  
  <p>Two Ways</p>
  
  <p><strong>Annotation Based - Works Fine</strong></p>
  
  <pre><code>@ControllerAdvice
  @Controller
  public class AppBindingInitializer {
  
      @InitBinder
      public void initBinder(WebDataBinder binder) {
          binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
      }
  
  }
  </code></pre>
  
  <p><strong>XML Based - Getting Error</strong></p>
  
  <pre><code>&lt;bean id="coreCustomEditors" class="org.springframework.beans.factory.config.CustomEditorConfigurer"&gt;
       &lt;property name="customEditors"&gt;
          &lt;map&gt;
              &lt;entry key="java.lang.String"&gt;
                  &lt;bean class="org.springframework.beans.propertyeditors.StringTrimmerEditor"&gt;
                      &lt;constructor-arg name="emptyAsNull" value="true" /&gt;
                  &lt;/bean&gt;
              &lt;/entry&gt;
          &lt;/map&gt;
      &lt;/property&gt;
   &lt;/bean&gt;
  </code></pre>
  
  <p><strong>Exception</strong></p>
  
  <pre><code>Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.util.LinkedHashMap' to required type 'java.util.Map' for property 'customEditors'; nested exc
  eption is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.beans.propertyeditors.StringTrimmerEditor] to required type [java.lang.Class] for property 'customEditor
  s[java.lang.String]': PropertyEditor [org.springframework.beans.propertyeditors.ClassEditor] returned inappropriate value of type [org.springframework.beans.propertyeditors.StringTrimmerEditor]
          at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:479)
          at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:511)
          at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:505)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1502)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1461)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
          ... 53 more
  Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.beans.propertyeditors.StringTrimmerEditor] to required type [java.lang.Class] for property 'customEdito
  rs[java.lang.String]': PropertyEditor [org.springframework.beans.propertyeditors.ClassEditor] returned inappropriate value of type [org.springframework.beans.propertyeditors.StringTrimmerEditor]
          at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:263)
          at org.springframework.beans.TypeConverterDelegate.convertToTypedMap(TypeConverterDelegate.java:623)
          at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:208)
          at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:459)
  </code></pre>