2016-12-22 1 views
0

EasyUIを使用してSpringブートサーバーに簡単な投稿要求を試みています。JQuery post、Spring Bootが不正なコンテンツタイプを返す

要求は同じくらい簡単です:

$.post('/company/delete', { 
     id:row.id 
    }, function(result) { 
     if (result.success) { 
      $('#dg').datagrid('reload'); // reload the user data 
     } else { 
      $.messager.show({ // show error message 
       title : 'Error', 
       msg : result.msg 
      }); 
     } 
    }, 'json'); 

とサーバ側:

@ResponseBody 
@RequestMapping(value = "/delete", method = RequestMethod.POST) 
public int delete(@RequestBody List<Company> JSONString){ 
    System.out.println("print json "+JSONString); 
    int userinfo = companyService.deleteByPrimaryKey(JSONString); 
    return userinfo; 
} 

私は、サーバーにJSONデータを投稿しますが、サーバーが悪いコンテンツタイプを返します。

Controller [com.supplyplatform.controller.CompanyController] 
Method [public int com.supplyplatform.controller.CompanyController.delete(java.util.List<com.supplyplatform.pojo.Company>)] 

org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported 

答えて

0

deleteメソッドで@RequestBodyを削除してみてください。

関連する問題