Eug*_*erg 15 java spring spring-boot
在我的spring boot REST API应用程序中,我需要通过接受强类型列表作为我的输入来处理HTTP POST:
@RestController
public class CusttableController {
static final Logger LOG = LoggerFactory.getLogger(CusttableController.class);
@RequestMapping(value="/custtable/update", method=RequestMethod.POST)
@ResponseBody
public String updateCusttableRecords(List<Custtable> customers) {
try {
for (Custtable cust : customers) {
Custtable customer = (Custtable) custtableDao.getById(Custtable.class,
new CusttableCompositeKey
(cust.getAccountnum(),cust.getPartition(),cust.getDataareaid()));
Run Code Online (Sandbox Code Playgroud)
在这个API的Jersey版本中,这个工作得很好,但是使用Spring Boot,它给了我这个错误:
org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface
Run Code Online (Sandbox Code Playgroud)
在Spring Boot中接受强类型列表的正确方法是什么?
Ego*_*nko 28
尝试将RequestBody注释添加到方法定义中
@RequestMapping(value="/custtable/update", method=RequestMethod.POST)
@ResponseBody
public String updateCusttableRecords(@RequestBody List<Custtable> customers) {
//Method body
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16605 次 |
最近记录: |