我有一个行代码,并将其在该版本的工作:如何在使用.getClass()时将参数传递给构造函数?
...
Wrapper<Model> wrapped = restTemplate.getForObject(BASE_URL, Wrapper.class, map);
...
不过,我想送参数的构造函数:
...
Wrapper<Model> wrapped = restTemplate.getForObject(BASE_URL, new Wrapper(Model.class).getClass(), map);
...
这引发了我的异常:
org.springframework.web.client.ResourceAccessException: I/O error: No suitable constructor found for type [simple type, class a.b.c.d.model.Wrapper]: can not instantiate from JSON object (need to add/enable type information?)
at [Source: [email protected]; line: 1, column: 3]; nested exception is org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type [simple type, class a.b.c.d.model.Wrapper]: can not instantiate from JSON object (need to add/enable type information?)
at [Source: [email protected]; line: 1, column: 3]
如何将参数发送给一个对象,我将获得它的类的值?
'Wrapper'是什么类?这是? - > http://download.oracle.com/javase/6/docs/api/java/sql/Wrapper.html –