Failed to instantiate [java.util.List]: Specified class is an interface

发布时间 2023-06-06 14:02:03作者: xiaoovo

原代码没加@RequestParam,一直给我报这个错,传这个List根本不行

@RequestMapping(value = "/searchPhoneInfos2", method = RequestMethod.GET)
    public  CommonResult searchPhoneInfos2(int page, int limit, String phoneName, List<String> brand, String system){
        int offset = (page - 1) * limit;
        CommonResult result = phoneServer.searchPhoneInfos2(limit, offset, phoneName, brand, system);
        return  result;
    }

解决办法就是加@RequestParam,原因不知道,能跑就行了。

@RequestMapping(value = "/searchPhoneInfos2", method = RequestMethod.GET)
    public  CommonResult searchPhoneInfos2(int page, int limit, String phoneName,@RequestParam(value = "brand", required = false) List<String> brand, String system){
        int offset = (page - 1) * limit;
        CommonResult result = phoneServer.searchPhoneInfos2(limit, offset, phoneName, brand, system);
        return  result;
    }