简体   繁体   中英

Spring MVC 3.2 Jackson Bad Request

I migrated from Spring 3.1 to Spring 3.2.5. before migrating to Spring 3.2.5 everything seems to be working howerver when I updated my library some of my rest calls are returning a 400 Bad Request.

Here's the method

    @RequestMapping(value = AJAX_SEARCH_MED)
    @ResponseBody
    DataTablesAjaxResponse<ActiveMedicationView> ajaxSearchActiveMedication(
            @PathVariable(PATH_PIN) String pin,
            @RequestBody DataTablesAjaxRequest request);

I already configured my mvc:annotation to this

<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
    <!-- Turn off working out content type based on URL file extension, should fall back to looking at the Accept headers -->
    <property name="favorPathExtension" value="false" />
</bean>

in my pom. I have this jackson marshalling library

  <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-mapper-asl</artifactId>
    <version>1.9.10</version>
  </dependency>

However when making calls from data tables I always receive a bad request.

在此处输入图片说明

The code calling the method

$('#prescriptionsTable').dataTable({
        "bProcessing":true,
        "bServerSide":true,
        "bFilter":false,
        "sAjaxSource":"/cms/ajax/patient/2012010000000009/active-medication.html",
        "aoColumnDefs":[ //Other configurations here

Try this configuration:

    @RequestMapping(value = AJAX_SEARCH_MED, method = RequestMethod.GET, headers="Content-Type=application/json")
        @ResponseBody
        public DataTablesAjaxResponse<ActiveMedicationView> ajaxSearchActiveMedication(
                @PathVariable(PATH_PIN) String pin,
                @RequestBody DataTablesAjaxRequest request)
{
// random code
};

If this doesn't fix it we can try to dig further to identify the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM