spring boot - how to avoid “Failed to instantiate [java.util.List]: Specified class is an interface” in HTTP controller handler?

后端 未结 2 1026
鱼传尺愫
鱼传尺愫 2021-02-19 02:28

In my spring boot REST API application, I need to handle HTTP POST by accepting a strongly-typed list as my input:

@RestController
public class CusttableControll         


        
相关标签:
2条回答
  • 2021-02-19 02:28

    For me I had made a typo accidentally wrapping a class in a list. Removing the typo allowed serialization to happen correctly via spring data rest + jackson.

    List<MyClass> a; // typo
    MyClass = a;// fix
    
    0 讨论(0)
  • 2021-02-19 02:45

    Try to add RequestBody annotation to your method definition

    @RequestMapping(value="/custtable/update", method=RequestMethod.POST)
    @ResponseBody
    public String updateCusttableRecords(@RequestBody List<Custtable> customers) {
        //Method body 
    }
    
    0 讨论(0)
提交回复
热议问题