[英]Spring MVC 3.2 Jackson Bad Request
I migrated from Spring 3.1 to Spring 3.2.5. 我从Spring 3.1迁移到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.
迁移到Spring 3.2.5之前,当我更新库时,一切似乎都无法正常工作,我的一些其余调用返回了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 我已经为此配置了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>
in my pom. 在我的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. 如果仍不能解决问题,我们可以尝试进一步挖掘以找出问题所在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.