当我发送类似getUserPlaces?page=0&size=5
的请求时
我收到此错误:
无法实例化[org.springframework.data.domain.Pageable]:指定的类是接口
我的控制器是:
@Controller
@EnableSpringDataWebSupport
public class UserController {
...
@RequestMapping(value = "/getUserPlaces", method = RequestMethod.POST)
public @ResponseBody List<PlaceDto> getUserPlaces(@RequestBody RoutePagingDto routeRequest, Pageable pageable) {
return placeService.placeToPlaceDto(userService.getUserPlaces(pageable));
}
在我的spring-context.xml中,我将它们声明为bean:
<beans:bean class="org.springframework.data.web.SortHandlerMethodArgumentResolver" />
<beans:bean class="org.springframework.data.web.PageableHandlerMethodArgumentResolver" />
我缺少什么?
最佳答案
从UserController类中删除@EnableSpringDataWebSupport
并使用以下代码创建WebConfig类
@Configuration
@EnableWebMvc
@EnableSpringDataWebSupport
public class WebConfig extends WebMvcConfigurationSupport {}