[英]Failed to instantiate [org.springframework.data.domain.Pageable]: Specified class is an interface
When I'm sending a request like getUserPlaces?page=0&size=5
I get this error: 当我发送类似
getUserPlaces?page=0&size=5
类的请求时,出现此错误:
Failed to instantiate [org.springframework.data.domain.Pageable]: Specified class is an interface
无法实例化[org.springframework.data.domain.Pageable]:指定的类是接口
My controller is: 我的控制器是:
@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));
}
In my spring-context.xml I have them declared beans: 在我的spring-context.xml中,我将它们声明为bean:
<beans:bean class="org.springframework.data.web.SortHandlerMethodArgumentResolver" />
<beans:bean class="org.springframework.data.web.PageableHandlerMethodArgumentResolver" />
What I'm missing? 我想念的是什么?
Remove @EnableSpringDataWebSupport
from UserController class and create WebConfig class with the following code 从UserController类中删除
@EnableSpringDataWebSupport
,并使用以下代码创建WebConfig类
@Configuration
@EnableWebMvc
@EnableSpringDataWebSupport
public class WebConfig extends WebMvcConfigurationSupport {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.