2

Do you know why I am getting this error?

SEVERE: Servlet.service() for servlet [enemr] in context with path [/enemr] threw exception [Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.github.dandelion.datatables.core.ajax.DatatablesCriterias]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.github.dandelion.datatables.core.ajax.DatatablesCriterias.<init>()] with root cause
java.lang.NoSuchMethodException: com.github.dandelion.datatables.core.ajax.DatatablesCriterias.<init>()

I changed my controller from this

@RequestMapping(value = "/results", method = RequestMethod.GET)
    public @ResponseBody DatatablesResponse<Results> findAllForDataTables(HttpServletRequest request) {

        DatatablesCriterias dataTableCriterias = DatatablesCriterias.getFromRequest(request);
        DataSet<Results> results = this.resultsServiceimpl.findResultsWithDatatablesCriterias(dataTableCriterias);
        return DatatablesResponse.build(results, dataTableCriterias);
    }

to this:

@RequestMapping(value = "/results", method = RequestMethod.GET)
    public @ResponseBody 
    DatatablesResponse<Results> findAllForDataTables(@DatatablesParams DatatablesCriterias criterias) {

        DataSet<Results> results = this.resultsServiceimpl.findResultsWithDatatablesCriterias(criterias);
        return DatatablesResponse.build(results, criterias);
    }

and suddenly stop working

any help highly appreciated.

I am using spring 3.2 and dandelion datatables 1.1.0

4

1 回答 1

1

当您更改控制器以使用DatatablesParams注释时,您需要启用将实例化DatatablesCriterias对象的解析器。因为使用的是spring 3.2,DatatablesCriteriasMethodArgumentResolver需要启用:

通过xml:

     <!-- Add support for @DatatablesParams annotations in controller's methods -->
   <mvc:annotation-driven>
      <mvc:argument-resolvers>
         <bean class="com.github.dandelion.datatables.extras.spring3.ajax.DatatablesCriteriasMethodArgumentResolver" />
      </mvc:argument-resolvers>
   </mvc:annotation-driven>

或java配置:

   @Configuration
   @EnableWebMvc
   public class MyWebConfig extends WebMvcConfigurerAdapter {
      @Override
      public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
         argumentResolvers.add(new DatatablesCriteriasMethodArgumentResolver());
      }
   }
于 2016-05-01T07:44:24.157 回答