【发布时间】:2015-02-03 18:07:55
【问题描述】:
当我发送像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 中,我将它们声明为 beans:
<beans:bean class="org.springframework.data.web.SortHandlerMethodArgumentResolver" />
<beans:bean class="org.springframework.data.web.PageableHandlerMethodArgumentResolver" />
我错过了什么?
【问题讨论】:
-
我认为
@EnableSpringDataWebSupport应该在一个不在此处的配置类中 -
在什么配置类上?
-
this 可能是相关的。
-
看看this 和this。作为@RC。提到,你不需要像
EnableSpringDataWebSupport,especially on controllers这样的注释。
标签: java spring spring-mvc