本文整理匯總了Java中org.springframework.data.web.PageableHandlerMethodArgumentResolver類的典型用法代碼示例。如果您正苦於以下問題:Java PageableHandlerMethodArgumentResolver類的具體用法?Java PageableHandlerMethodArgumentResolver怎麽用?Java PageableHandlerMethodArgumentResolver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PageableHandlerMethodArgumentResolver類屬於org.springframework.data.web包,在下文中一共展示了PageableHandlerMethodArgumentResolver類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setup
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Before
public void setup() {
this.mockMvc = standaloneSetup(new PostController(postService, posts, comments))
.setCustomArgumentResolvers(
new PageableHandlerMethodArgumentResolver()
)
// .setViewResolvers(new ViewResolver() {
// @Override
// public org.springframework.web.servlet.View resolveViewName(String viewName, Locale locale)
// throws Exception {
// return new MappingJackson2JsonView(objectMapper);
// }
// })
.setMessageConverters(
new MappingJackson2HttpMessageConverter(objectMapper)
)
.alwaysDo(print())
.apply(springSecurity(springSecurityFilterChain))
.build();
}
示例2: addArgumentResolvers
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
Sort defaultSort = new Sort(new Sort.Order(Sort.Direction.ASC, "id"));
Pageable defaultPage = new PageRequest(0, 10, defaultSort);
SortHandlerMethodArgumentResolver sortHandlerMethodArgumentResolver = new SortHandlerMethodArgumentResolver();
sortHandlerMethodArgumentResolver.setSortParameter("sort");
sortHandlerMethodArgumentResolver.setFallbackSort(defaultSort);
PageableHandlerMethodArgumentResolver pageableResolver = new PageableHandlerMethodArgumentResolver();
pageableResolver.setMaxPageSize(100);
pageableResolver.setOneIndexedParameters(false);
pageableResolver.setPageParameterName("page");
pageableResolver.setSizeParameterName("size");
pageableResolver.setFallbackPageable(defaultPage);
argumentResolvers.add(sortHandlerMethodArgumentResolver);
argumentResolvers.add(pageableResolver);
}
示例3: testDefaultRepositoryConfiguration
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Test
public void testDefaultRepositoryConfiguration() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(TestConfiguration.class,
EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class,
JpaRepositoriesAutoConfiguration.class,
SpringDataWebAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
assertThat(this.context.getBean(PageableHandlerMethodArgumentResolver.class))
.isNotNull();
assertThat(this.context.getBean(FormattingConversionService.class)
.canConvert(Long.class, City.class)).isTrue();
}
示例4: testDefaultRepositoryConfiguration
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Test
public void testDefaultRepositoryConfiguration() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(TestConfiguration.class,
EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class,
JpaRepositoriesAutoConfiguration.class,
SpringDataWebAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(CityRepository.class));
assertNotNull(this.context.getBean(PageableHandlerMethodArgumentResolver.class));
assertTrue(this.context.getBean(FormattingConversionService.class)
.canConvert(Long.class, City.class));
}
示例5: mvcViewConfigurer
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Bean
public WebMvcConfigurerAdapter mvcViewConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("search");
registry.addViewController("/monitor").setViewName("monitor");
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(new PageableHandlerMethodArgumentResolver());
}
};
}
示例6: setUp
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Before
public void setUp() throws GeoLocationException {
final ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver();
final StaticApplicationContext applicationContext = new StaticApplicationContext();
applicationContext.registerBeanDefinition("solrController",
new RootBeanDefinition(SolrController.class, null, null));
exceptionResolver.setApplicationContext(applicationContext);
exceptionResolver.afterPropertiesSet();
mockProductService = mock(ProductService.class);
String badLocation = "35.453487-97.5184727";
when(mockProductService.getProductsByLocation(badLocation)).thenThrow(new GeoLocationException());
solrController = new SolrController(mockProductService);
mockMvc = MockMvcBuilders.standaloneSetup(solrController)
.setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver())
.setHandlerExceptionResolvers(exceptionResolver).build();
product = createProduct(1000);
when(mockProductService.getProduct(PRODUCT_ID)).thenReturn(product);
allProducts = createProductList(10);
when(mockProductService.getProducts()).thenReturn(allProducts);
}
示例7: addArgumentResolvers
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
PageableHandlerMethodArgumentResolver pageResolver =
new PageableHandlerMethodArgumentResolver();
pageResolver.setFallbackPageable(new PageRequest(0, 10));
argumentResolvers.add(pageResolver);
}
示例8: getListOfWorkflows
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
/**
* Get the full list of workflows
* TODO: Mock the repository and test model attributes
*/
@Test
public void getListOfWorkflows() throws Exception {
// Mock controller/MVC
WorkflowController workflowController = new WorkflowController(
Mockito.mock(WorkflowFormValidator.class),
Mockito.mock(WorkflowService.class),
Mockito.mock(GraphVizService.class));
// Lots of hassle to make Spring Data Pageable work
PageableHandlerMethodArgumentResolver pageableArgumentResolver =
new PageableHandlerMethodArgumentResolver();
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/src/main/resources/templates");
viewResolver.setSuffix(".html");
MockMvc mockMvc = MockMvcBuilders
.standaloneSetup(workflowController)
.setCustomArgumentResolvers(pageableArgumentResolver)
.setViewResolvers(viewResolver)
.build();
// Simple test to check the view
mockMvc.perform(get("/workflows"))
.andExpect(status().isOk())
.andExpect(view().name("workflows"));
}
示例9: addArgumentResolvers
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
PageableHandlerMethodArgumentResolver resolver = new PageableHandlerMethodArgumentResolver();
resolver.setOneIndexedParameters(true);
resolver.setFallbackPageable(new PageRequest(0, 10));
argumentResolvers.add(resolver);
super.addArgumentResolvers(argumentResolvers);
}
示例10: addArgumentResolvers
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
PageableHandlerMethodArgumentResolver pageableHandlerMethodArgumentResolver = new PageableHandlerMethodArgumentResolver();
pageableHandlerMethodArgumentResolver.setMaxPageSize(20);
pageableHandlerMethodArgumentResolver
.setFallbackPageable(new PageRequest(0, 20, new Sort(Direction.DESC, "dateCreated")));
argumentResolvers.add(pageableHandlerMethodArgumentResolver);
}
示例11: addArgumentResolvers
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
PageableHandlerMethodArgumentResolver resolver = new PageableHandlerMethodArgumentResolver();
resolver.setFallbackPageable(new PageRequest(
Pagination.DEFAULT_PAGE_NUMBER,
Pagination.NO_PAGINATION));
argumentResolvers.add(resolver);
super.addArgumentResolvers(argumentResolvers);
}
示例12: webSupportIsAutoConfiguredInWebApplicationContexts
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Test
public void webSupportIsAutoConfiguredInWebApplicationContexts() {
this.context = new AnnotationConfigWebApplicationContext();
((AnnotationConfigWebApplicationContext) this.context)
.register(SpringDataWebAutoConfiguration.class);
this.context.refresh();
((AnnotationConfigWebApplicationContext) this.context)
.setServletContext(new MockServletContext());
Map<String, PageableHandlerMethodArgumentResolver> beans = this.context
.getBeansOfType(PageableHandlerMethodArgumentResolver.class);
assertThat(beans).hasSize(1);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:13,代碼來源:SpringDataWebAutoConfigurationTests.java
示例13: autoConfigurationBacksOffInNonWebApplicationContexts
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Test
public void autoConfigurationBacksOffInNonWebApplicationContexts() {
this.context = new AnnotationConfigApplicationContext();
((AnnotationConfigApplicationContext) this.context)
.register(SpringDataWebAutoConfiguration.class);
this.context.refresh();
Map<String, PageableHandlerMethodArgumentResolver> beans = this.context
.getBeansOfType(PageableHandlerMethodArgumentResolver.class);
assertThat(beans).isEmpty();
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:11,代碼來源:SpringDataWebAutoConfigurationTests.java
示例14: pageableResolver
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Bean
public PageableHandlerMethodArgumentResolver pageableResolver() {
PageableHandlerMethodArgumentResolver pageableHandlerMethodArgumentResolver = new PageableHandlerMethodArgumentResolver(sortResolver());
pageableHandlerMethodArgumentResolver.setPageParameterName("page");
pageableHandlerMethodArgumentResolver.setOneIndexedParameters(true);
pageableHandlerMethodArgumentResolver.setSizeParameterName("limit");
return pageableHandlerMethodArgumentResolver;
}
示例15: webSupportIsAutoConfiguredInWebApplicationContexts
import org.springframework.data.web.PageableHandlerMethodArgumentResolver; //導入依賴的package包/類
@Test
public void webSupportIsAutoConfiguredInWebApplicationContexts() {
this.context = new AnnotationConfigWebApplicationContext();
((AnnotationConfigWebApplicationContext) this.context)
.register(SpringDataWebAutoConfiguration.class);
this.context.refresh();
((AnnotationConfigWebApplicationContext) this.context)
.setServletContext(new MockServletContext());
Map<String, PageableHandlerMethodArgumentResolver> beans = this.context
.getBeansOfType(PageableHandlerMethodArgumentResolver.class);
assertThat(beans.size(), is(equalTo(1)));
}