title: how to convert uri string to complex object type in spring
body: <p>i just wonder, can i convert uri string to another object type ?</p>
  
  <pre><code>    @RequestMapping(value="/key/{keyDomain}", method=RequestMethod.GET)
      public String propertyEditor(@PathVariable(value="keyDomain") KeyDomain key, Model model){
          model.addAttribute("key", key);
          return "propertyEditor";
      }
  </code></pre>
  
  <p>and here my configuration</p>
  
  <pre><code>&lt;beans:bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer"&gt;
          &lt;beans:property name="customEditors"&gt;
              &lt;beans:map&gt;
                  &lt;!-- &lt;beans:entry key="com.template.baseline.domain.KeyDomain" value="com.template.baseline.propertyEditor.KeyPropertyEditor"/&gt;  --&gt;
                  &lt;beans:entry key="com.template.baseline.domain.KeyDomain"&gt;
                      &lt;beans:ref bean="keyDomainPropertyEditor"  /&gt;
                  &lt;/beans:entry&gt;
              &lt;/beans:map&gt;
          &lt;/beans:property&gt;
      &lt;/beans:bean&gt;
  
  &lt;!-- key domain property editor bean --&gt;
  &lt;beans:bean id="keyDomainPropertyEditor"  class="com.template.baseline.propertyEditor.KeyPropertyEditor"&gt;
      &lt;beans:property name="keyDomain"&gt;
          &lt;beans:bean class="com.template.baseline.domain.KeyDomain" /&gt;
      &lt;/beans:property&gt;   
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>and propertyEditor Class :</p>
  
  <pre><code>public class KeyPropertyEditor extends PropertyEditorSupport{
  
      private KeyDomain keyDomain;
  
      /**
       * example : 10435
       * - 10 will be keyId
       * - 435 will be baseOfficeId
       */
      @Override
      public void setAsText(String text) throws IllegalArgumentException{
          KeyDomain keyDomain = new KeyDomain();
          keyDomain.setKeyId(Integer.parseInt(text.substring(0,1)));
          keyDomain.setBaseOfficeId(Integer.parseInt(text.substring(2,4)));       
          setValue(keyDomain);
      }
  
      @Override
      public String getAsText() {
          KeyDomain value = (KeyDomain) getValue();
          return (value != null ? value.toString() : "");
      }
  
      public void setKeyDomain(KeyDomain keyDomain) {
          this.keyDomain = keyDomain;
      }   
  }
  </code></pre>
  
  <p>i thought that i can use Property Editor to convert my URI string become appropriate  object type. i already made an implementation and configure CustomEditorConfigurer, but i always get ConversionNotSupportedException.</p>
  
  <p>if i add initBinder at my controller, everything will just fine :</p>
  
  <pre><code>@InitBinder
  public void setBinder(WebDataBinder dataBinder) {
      dataBinder.registerCustomEditor(KeyDomain.class, new KeyPropertyEditor());      
  }
  </code></pre>
  
  <p>and i get Warning something like this</p>
  
  <blockquote>
    <p>WARN : org.springframework.beans.factory.config.CustomEditorConfigurer - Passing PropertyEditor instances into CustomEditorConfigurer is deprecated: use PropertyEditorRegistrars or PropertyEditor class names instead. Offending key [com.template.baseline.domain.KeyDomain; offending editor instance: com.template.baseline.propertyEditor.KeyPropertyEditor@1a271f5</p>
  </blockquote>
  
  <p>thanks for the answer.</p>
  
  <p>ps : webBindingInitalizer injected on AnnotationMethodHandlerAdapter</p>
  
  <pre><code>&lt;beans:bean id="AnnotationMethodHandlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
      &lt;beans:property name="webBindingInitializer"&gt;
          &lt;beans:bean class="com.template.baseline.initialize.CustomWebBindingInitializer" /&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>and Implementation</p>
  
  <pre><code>public class CustomWebBindingInitializer implements WebBindingInitializer  {
  
  public CustomWebBindingInitializer(){
      System.out.println("******** constructor *********");
  }
  
  public void initBinder(WebDataBinder binder, WebRequest request) {
      System.out.println("******** initBinder *********");
      binder.registerCustomEditor(KeyDomain.class, new KeyDomainPropertyEditor());
  }
  </code></pre>
  
  <p>}</p>