Spring Rest分页未显示正确的结果

Spring Rest分页未显示正确的结果,rest,spring-data,Rest,Spring Data,有人能帮我分页吗?这是我的控制器方法代码 @RequestMapping(method = RequestMethod.GET, value = "/search") @ResponseBody public HttpEntity<PagedResources<OrderResource>> search( @Valid OrderSearch search, @PageableDefault(size=5) @SortDefault(so

有人能帮我分页吗?这是我的控制器方法代码

@RequestMapping(method = RequestMethod.GET, value = "/search")
@ResponseBody
public HttpEntity<PagedResources<OrderResource>> search(
        @Valid OrderSearch search,
        @PageableDefault(size=5) @SortDefault(sort = "poNumber", direction = Sort.Direction.DESC) Pageable pageable) {
    Page<Order> orders = orderService.search(search, pageable);
    return new ResponseEntity<PagedResources<OrderResource>>(
            pagedAssembler.toResource(orders, orderAssembler),
            HttpStatus.OK);
}
下一个链接中出现
page=1
的任何原因,以及当我点击下方时,记录都不会刷新

这是我的servlet配置

<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="webBindingInitializer">
            <bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
                <property name="conversionService" ref="conversionService" />
            </bean>
        </property>
        <property name="messageConverters">
            <list>
                <!-- Handle XML input -->
                <ref bean="jaxbHttpMessageConverter" />
                <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />

            </list>
        </property>
        <property name="customArgumentResolvers">
            <list>
                <bean class="org.springframework.data.web.PageableArgumentResolver" />
            </list>
        </property>
    </bean>

   <bean id= "conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />

   <bean id="sortResolver" class="org.springframework.data.web.HateoasSortHandlerMethodArgumentResolver" />

   <bean  class="org.springframework.data.web.PagedResourcesAssembler">
        <constructor-arg>
            <bean class="org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver">
               <constructor-arg ref="sortResolver" />
            </bean>
        </constructor-arg>
        <constructor-arg>
            <null />
        </constructor-arg>
 </bean>

   <bean class="org.springframework.data.web.config.SpringDataWebConfiguration" /> 

    <!-- Configure the XML JAXB marshaller  -->
    <bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="contextPath" value="com.emc.it.eis.channeltracker.model" />
    </bean>

    <!-- Message converter for XML requests and responses -->
    <bean id="jaxbHttpMessageConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
        <property name="marshaller" ref="jaxb2Marshaller" />
        <property name="unmarshaller" ref="jaxb2Marshaller" />
    </bean>


页面
默认为零索引,就像Java中的
列表
一样。0划分第一页,1划分第二页,依此类推

这可以通过将自定义的
HateoasPageableHandlerMethodArgumentResolver
管道连接到您使用的
PagedResourcesAssembler
进行调整。在前者上,将
setOneIndexedParameters(…)
配置为
true


这将导致HTTP交互(即请求参数)与一个索引页面一起工作:即
?page=1
将请求第一个页面,然后第二个页面的链接将指向
?page=2
。请注意,
Pageable
Page
实例在内部仍将使用零索引,因为它们是纯值对象,并且会相应地进行操作。

Oliver,我已经添加了我当前的servlet配置,我想我的配置与您建议的相同,但是请检查并告知我是否需要添加任何内容,另外,当我转到page2链接时,请告诉我为什么我看不到更新的结果,从技术上讲,我应该看到下一个堆栈,如果你看我有@PageableDefault(size=5),但当我第一次点击url时,我仍然看到10个结果
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="webBindingInitializer">
            <bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
                <property name="conversionService" ref="conversionService" />
            </bean>
        </property>
        <property name="messageConverters">
            <list>
                <!-- Handle XML input -->
                <ref bean="jaxbHttpMessageConverter" />
                <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />

            </list>
        </property>
        <property name="customArgumentResolvers">
            <list>
                <bean class="org.springframework.data.web.PageableArgumentResolver" />
            </list>
        </property>
    </bean>

   <bean id= "conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />

   <bean id="sortResolver" class="org.springframework.data.web.HateoasSortHandlerMethodArgumentResolver" />

   <bean  class="org.springframework.data.web.PagedResourcesAssembler">
        <constructor-arg>
            <bean class="org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver">
               <constructor-arg ref="sortResolver" />
            </bean>
        </constructor-arg>
        <constructor-arg>
            <null />
        </constructor-arg>
 </bean>

   <bean class="org.springframework.data.web.config.SpringDataWebConfiguration" /> 

    <!-- Configure the XML JAXB marshaller  -->
    <bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="contextPath" value="com.emc.it.eis.channeltracker.model" />
    </bean>

    <!-- Message converter for XML requests and responses -->
    <bean id="jaxbHttpMessageConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
        <property name="marshaller" ref="jaxb2Marshaller" />
        <property name="unmarshaller" ref="jaxb2Marshaller" />
    </bean>