I don't know if this will be any help since it's not quite the same as what you're doing, but this is working for me.
In my case I'm doing it as an ajax call, and I'm posting the array (and nothing else) using JSON.stringify(). Not sure how you would modify this if you're passing additional fields.
client side JavaScript:
Code:
var serverData = [];
// ... populate serverData
$.ajax({
type: 'POST',
url: sPostUrl,
data: JSON.stringify(serverData),
success: function(..) {
...
},
error: function(...) {
...
},
contentType: "application/json"
server side Java:
Code:
@RequestMapping(value = "yourUrlHere", method = RequestMethod.POST)
@ResponseBody
public String yourMethodName(HttpSession session, @RequestBody PostedClass[] postedItems) {
...
}
Also, I don't like using "YourClass[]". I thought I should be able to do it as a List<PostedClass>, but I was getting errors doing it that way.
Edit:
I forgot - I believe to be able to handle the JSON as input I had to add a AnnotationMethodHandlerAdapter to my servlet config. The default Spring 3.1 one did not include org.springframework.http.converter.json.MappingJac ksonHttpMessageConverter. The first 5 message converters are what Spring uses by default (see here). I had to add the MappingJacksonHttpMessageConverter.
Code:
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="order" value="1" />
<property name="messageConverters">
<list>
<!-- Message converters -->
<bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
<bean class="org.springframework.http.converter.FormHttpMessageConverter"/>
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>