Wednesday, 15 July 2015

Spring Rest Paging not displaying correct results -


Can anyone help me endorsement, here is my admin method code

  @ RequestMapping (method = RequestMethod.GET, value = "/ search") @ ResponseBodyBody Public HTTP Entitlement & Lt; Pager resources & lt; OrderResource & gt; & Gt; Search (@ legitimate order search search, @possible default (size = 5) @SortDefault (Sort = "PONM", Direction = Sort.Directation. DESC) to make page) {page & lt; Order & gt; Order = order service Search (Search, Page Eligible); New Response & lt; PagedResources & lt; OrderResource & gt; & Gt; (PagedAssembler.toResource (Order, Order Assembler), HTTP Stats.Ok); }  

I have received about 22 records in the table and it displays the page quality when I first press the controller

  {"metadata" : "", "Total Size": 10, "Total Elements": 22, "Total Pages": 3, "Number": 0}, "Next Link": {"rel": "Next", "href": " Http: // localhost: 8080 / restap / order / search? Pnm = 1000 and page = 1 & amp; size = 10 "," variable name ": []," variables ": []," tomplated ": false}, "Previous Links": Blank,  

Here's My Overlate Config

  & lt; Bean class = "org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> & Lt; Bean class = "org.springframework.web.servlet.mvc.annotation.nnationMethodHandlerAdapter" & gt; & Lt; Property Name = "Webbanking Instifier" & gt; & Lt; Bean class = "org.springframework.web.bind.support.ConfigurableWebBindingInitializer" & gt; & Lt; Property Name = "Conversion Service" Riff = "Conversion Service" /> & Lt; / Bean & gt; & Lt; / Property & gt; & Lt; Property Name = "Message Converters" & gt; & Lt; List & gt; & Lt ;! - Handle XML Input - & gt; & Lt; Ref bean = "jaxbHttpMessageConverter" /> & Lt; Bean square = "org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" /> & Lt; / List & gt; & Lt; / Property & gt; & Lt; Property Name = "Custom Argarg Resolver" & gt; & Lt; List & gt; & Lt; Bean square = "org.springframework.data.web.PageableArgumentResolver" /> & Lt; / List & gt; & Lt; / Property & gt; & Lt; / Bean & gt; & Lt; Bean id = "Conversion service" category = "org.springframework.format.support.FormattingConversionServiceFactoryBean" /> & Lt; Bean id = "SorterSolver" class = "org.springframework.data.web.HateoasSortHandlerMethodArgumentResolver" /> & Lt; Bean class = "org.springframework.data.web.PagedResourcesAssembler" & gt; & Lt; Manufacturer-Arg & gt; & Lt; Bean class = "org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver" & gt; & Lt; Constructor-arg ref = "sorterSolver" /> & Lt; / Bean & gt; & Lt; / Creator-arg & gt; & Lt; Manufacturer-Arg & gt; & Lt; Null / & gt; & Lt; / Creator-arg & gt; & Lt; / Bean & gt; & Lt; Bean square = "org.springframework.data.web.config.SpringDataWebConfiguration" /> & Lt ;! - Configure XML JAXB Marshler - & gt; & Lt; Bean id = "jaxb2mershaller" category = "org.springframework.oxm.jaxb.Jaxb2Marshaller" & gt; & Lt; Property Name = "ReferencePath" value = "com.emc.it.eis.channeltracker.model" /> & Lt; / Bean & gt; & Lt ;! - Message converter for XML requests and responses - & gt; & Lt; Bean id = "jaxbHttpMessageConverter" class = "org.springframework.http.converter.xml.MarshallingHttpMessageConverter" & gt; & Lt; Property Name = "Marshaller" Ref = "Jaxb 2 Marshler" /> & Lt; Property Name = "Unmarshaler" ref = "jaxb2marshaller" /> & Lt; / Bean & gt;  

page s Zero is indexed by default, such as list s is in Java 0 first page, 1 second and so on.

This can be used by piping a custom HateoasPageableHandlerMethodArgumentResolver to PagedResourcesAssembler . In the past, configured setOneIndexedParameters (...) to true .

This will work with HTTP interaction (i.e. request parameter) one-indexed pages: i.e. ? Page = 1 will request the first page and then link to the second page ? Page = 2 . Note, the pageable and pages examples will still use zero-indexing because they are plain value objects and behave accordingly.


No comments:

Post a Comment