Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I also got </p> <pre><code>2012-06-26 12:41:55,215 DEBUG DefaultHandlerExceptionResolver - Resolving exception from handler [public org.springframework.http.ResponseEntity&lt;Resource&lt;java.lang.Object&gt;&gt; StatisticsController.getStats(java.util.Date)]: org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.util.Date]: no matching editors or conversion strategy found </code></pre> <p>when trying to call to my controller method</p> <pre><code>public ResponseEntity&lt;Resource&lt;Object&gt;&gt; getStats(@RequestParam Date fromDate) </code></pre> <p>Reading about ConversionServiceFactoryBean on </p> <p><a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html" rel="nofollow">http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html</a></p> <p>indicates that date support requires JODA time which we didn't want. So I tried to add my own converter (that implements Converter) to ConversionServiceFactoryBean </p> <pre><code>&lt;bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"&gt; &lt;property name="converters"&gt; &lt;list&gt; &lt;bean class="MyStringToDateConverter"/&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>and also bound this to the mvc-annotation driven tag: </p> <pre><code>&lt;mvc:annotation-driven conversion-service="conversionService"/&gt; </code></pre> <p>But I never got my converter to kick in. I always got "no matching editors or conversion strategy found".</p> <p>As indicated above I was hoping to use the Spring MVC 3.x style of conversion service but I had to go for the workaround with the old approach with init binder. </p> <pre><code>/** * I would claim this is should not be needed in Spring 3.x with ConversionServiceFactoryBean * @param binder */ @InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); } </code></pre> <p>This worked immediately. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload