I try to send a request in the Form:
list=Apple1&list=Apple2&list=Apple3
whereas Apple is a complex object which is serialized in JSON:
{"param1":"value1", "param2":"value2"}
I defined a Dispatcher Servlet in Spring to receive such requests, with a method like:
request(@RequestParam("list") POJO[] pojos){
//handle request
}
it is no problem to send a single POJO to such a method like
request(@RequestParam("single") POJO pojos){
//handle request
}
but as soon I try to transmit an Array Spring is dying with an Exception like:
java.lang.NoSuchMethodException: [Lmy.package.Apple;.<init>()
How can I teach the dispatcher servlet to deserialize arrays correctly?
Thanks for you help
I had this error when I added the @RequestParam annotation to an interface my dispatcher servlet implements, not to the dispatcher servlet itself. In this case Spring would ignore the annotation and try to instantiate the array of apples directly, what would result in the error message you supplied:
java.lang.NoSuchMethodException: [Lmy.package.Apple;.<init>().