问题
The default MVC model binder (System.Web.Mvc.DefaultModelBiner
) correctly binds the following syntax of nested arrays:
array[0].propertyA=valueA&array[0].propertyB=valueB& ...etc
To the following action method:
public ActionResult AjaxHandler(Part[] array, ...)
However, jQuery.param() is only able to serialize into the following syntax :
array[0][propertyA]=valueA&array[0][propertyB]=valueB& ...etc
Setting traditional
flag to true still produces incorrect mapping:
array=[object+Object]&...etc
I was checking out DefaultModelBinder.cs but that class is something like 900 lines of code and would take quite some time to dissect.
I'm looking for some pointers on which members to override or an implementation would be even more appreciated.
来源:https://stackoverflow.com/questions/17558735/overriding-mvc-defaultmodelbinder-to-handle-arrays-of-complex-objects