@RequestMapping(value = "/tester/", method = RequestMethod.POST)
public String testingonly(@RequestBody List<EachObject> eachobjectlist) throws IOException {
then i do iterate eachobjectlist, but each item inside the list is type LinkedHashMap, arent it suppose to be “EachObject” type ?
Due to type erasure at runtime, the generic typeEachObjectis not present at runtime. Spring will not be able to determine this information. Spring only knows that the argument has a raw typeListand it will inject aListof any type.According to @axtavt, generic types of method’s arguments are accessible but Spring may not have this implemented and probably won’t be implemented in the future. This is because generic type can be interface or abstract class and Spring will not be able to create a corresponding implementation of a given interface or abstract class. For example, if you request for a list of
Fruitand there are two almost identical subclasses ofFruit, dertemining which subclass to be used will not be possible.