我从 Spring 3.1 迁移到 Spring 3.2.5。在迁移到 Spring 3.2.5 之前,一切似乎都正常,但是当我更新我的库时,我的一些其余调用返回了 400 Bad Request。
方法如下
@RequestMapping(value = AJAX_SEARCH_MED)
@ResponseBody
DataTablesAjaxResponse<ActiveMedicationView> ajaxSearchActiveMedication(
@PathVariable(PATH_PIN) String pin,
@RequestBody DataTablesAjaxRequest request);
我已经配置了我的 mvc:annotation
<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>
在我的 pom.我有这个 jackson 编码库
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.10</version>
</dependency>
但是,当从数据表进行调用时,我总是收到错误的请求。
调用方法的代码
$('#prescriptionsTable').dataTable({
"bProcessing":true,
"bServerSide":true,
"bFilter":false,
"sAjaxSource":"/cms/ajax/patient/2012010000000009/active-medication.html",
"aoColumnDefs":[ //Other configurations here
最佳答案
尝试这个配置:
@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
};
如果这不能解决问题,我们可以尝试进一步挖掘以找出问题。
关于java - Spring MVC 3.2 Jackson 错误请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24566706/