当我发送诸如 getUserPlaces?page=0&size=5
之类的请求时
我收到此错误:
Failed to instantiate [org.springframework.data.domain.Pageable]: Specified class is an interface
我的 Controller 是:
@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" />
我缺少什么?
最佳答案
从 UserController 类中删除 @EnableSpringDataWebSupport
并使用以下代码创建 WebConfig 类
@Configuration
@EnableWebMvc
@EnableSpringDataWebSupport
public class WebConfig extends WebMvcConfigurationSupport {}
关于java - 无法实例化[org.springframework.data.domain.Pageable] : Specified class is an interface,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28305786/