我有一個行代碼,並將其在該版本的工作:如何在使用.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 –